diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 91bc539..609feec 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -8,7 +8,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ["3.7", "3.8", "3.9", "3.10"] + python-version: ["3.8", "3.9", "3.10"] # Ensure that all flavours are run to completion even if an other flavor failed fail-fast: false diff --git a/Makefile b/Makefile index a7eaf0a..7690e58 100644 --- a/Makefile +++ b/Makefile @@ -117,15 +117,15 @@ flake8: venv @printf "${TERM_BRIGHT}FLAKE8 ${ALL_SRCS}\n${TERM_NONE}" ${Q} ${CURDIR}/venv/bin/flake8 --select=F,C90 $(ALL_SRCS) -.PHONY: black -black: venv - @printf "${TERM_BRIGHT}BLACK ${ALL_SRCS}\n${TERM_NONE}" - ${Q} ${CURDIR}/venv/bin/black --check --diff $(ALL_SRCS) || { echo "Formatting errors found, try running 'make format'."; exit 1; } +.PHONY: ruff +ruff: venv + @printf "${TERM_BRIGHT}RUFF check ${ALL_SRCS}\n${TERM_NONE}" + ${Q} ${CURDIR}/venv/bin/ruff check --diff $(ALL_SRCS) || { echo "Formatting errors found, try running 'make format'."; exit 1; } -.PHONY: format_black -format_black: venv +.PHONY: format_ruff +format_ruff: venv @printf "${TERM_BRIGHT}FORMAT BLACK ${ALL_SRCS}\n${TERM_NONE}" - ${Q} ${CURDIR}/venv/bin/black $(ALL_SRCS) + ${Q} ${CURDIR}/venv/bin/ruff format $(ALL_SRCS) .PHONY: tests tests: \ @@ -134,12 +134,12 @@ tests: \ pytest_tests \ mypy \ flake8 \ - black \ + ruff \ check-copyright .PHONY: format format: \ - format_black + format_ruff @true ## ## Coverage diff --git a/requirements-dev.txt b/requirements-dev.txt index f4c633e..b72c75d 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,4 +1,4 @@ -black +ruff coverage coveralls flake8 diff --git a/testslide/bdd/dsl.py b/testslide/bdd/dsl.py index e66eedf..c4a5b8b 100644 --- a/testslide/bdd/dsl.py +++ b/testslide/bdd/dsl.py @@ -201,7 +201,7 @@ def nest_context(self, name: str, *args: Any, **kwargs: Any) -> None: raise TypeError('Shared context "{}" does not exist'.format(name)) self._create_context( name, - self.current_context.all_shared_contexts[name], + self.current_context.all_shared_contexts[name], # type: ignore *args, **kwargs, # type: ignore ) diff --git a/testslide/bdd/lib.py b/testslide/bdd/lib.py index de6d36f..31bcaa9 100644 --- a/testslide/bdd/lib.py +++ b/testslide/bdd/lib.py @@ -429,7 +429,7 @@ def addError( # type:ignore # inconsistently. def addFailure( # type:ignore self, - test: "TestCase", + test: "TestCase", # type: ignore err: Tuple[ Type[BaseException], BaseException, @@ -456,9 +456,9 @@ def addUnexpectedSuccess(self, test: "TestCase") -> None: # type: ignore # pyre-ignore def addSubTest( self, - test: "TestCase", - subtest: "TestCase", - err: Tuple[ + test: "TestCase", # type: ignore + subtest: "TestCase", # type: ignore + err: Tuple[ # type: ignore Optional[Type[BaseException]], Optional[BaseException], Optional[types.TracebackType], @@ -532,7 +532,7 @@ class Context: def __init__( self, name: str, - parent_context: Optional["Context"] = None, + parent_context: Optional["Context"] = None, # type: ignore shared: bool = False, skip: bool = False, focus: bool = False, diff --git a/testslide/cli.pyi b/testslide/cli.pyi index 89fc06a..328b050 100644 --- a/testslide/cli.pyi +++ b/testslide/cli.pyi @@ -1,6 +1,6 @@ # pyre-unsafe from testslide.executor.cli import * -from testslide.executor.import_profiler import ImportedModule, ImportProfiler +from testslide.executor.import_profiler import ImportedModule, ImportProfiler # noqa # pyre-fixme[21]: Could not find name `AggregatedExceptions` in # `testslide.executor.lib`. diff --git a/testslide/core/mock_callable.py b/testslide/core/mock_callable.py index 868c2b4..722652e 100644 --- a/testslide/core/mock_callable.py +++ b/testslide/core/mock_callable.py @@ -170,7 +170,7 @@ def _is_coroutine(obj: Any) -> bool: return inspect.iscoroutine(obj) or isinstance( obj, # pyre-ignore - asyncio.coroutines.CoroWrapper, + asyncio.coroutines.CoroWrapper, # type: ignore ) else: return inspect.iscoroutine(obj) @@ -1014,7 +1014,7 @@ def to_raise( _RaiseRunner( self._original_target, self._method, - self._original_callable, + self._original_callable, # type: ignore ex, # type: ignore ) ) @@ -1023,7 +1023,7 @@ def to_raise( _RaiseRunner( self._original_target, self._method, - self._original_callable, + self._original_callable, # type: ignore ex(), # type: ignore ) ) @@ -1246,7 +1246,7 @@ def with_implementation(self, func: Callable) -> "_MockAsyncCallableDSL": _AsyncImplementationRunner( self._original_target, self._method, - self._original_callable, + self._original_callable, # type: ignore func, # type: ignore ) ) diff --git a/testslide/core/mock_constructor.py b/testslide/core/mock_constructor.py index cebd472..19813c4 100644 --- a/testslide/core/mock_constructor.py +++ b/testslide/core/mock_constructor.py @@ -341,7 +341,7 @@ def mock_constructor( if target_class_id in _mocked_target_classes: original_class, mocked_class = _mocked_target_classes[target_class_id] - if not getattr(target, class_name) is mocked_class: + if getattr(target, class_name) is not mocked_class: raise AssertionError( "The class {} at {} was changed after mock_constructor() mocked " "it!".format(class_name, target) diff --git a/testslide/executor/cli.py b/testslide/executor/cli.py index e0f8092..fc64eee 100644 --- a/testslide/executor/cli.py +++ b/testslide/executor/cli.py @@ -158,7 +158,7 @@ def example_code(self: Any) -> None: "{}.{}".format( test_case.__module__, # pyre-ignore - test_case.__name__, + test_case.__name__, # type: ignore ) )(get_context_code(test_case)) diff --git a/testslide/executor/runner.py b/testslide/executor/runner.py index 3781b9b..cfe7329 100644 --- a/testslide/executor/runner.py +++ b/testslide/executor/runner.py @@ -532,7 +532,7 @@ def finish(self, not_executed_examples: List[Example]) -> None: print("") self.print_failed_example( number + 1, - result["example"], + result["example"], # type: ignore result["exception"], # type: ignore ) print("") diff --git a/testslide/lib.pyi b/testslide/lib.pyi index 948ad4d..7a7a122 100644 --- a/testslide/lib.pyi +++ b/testslide/lib.pyi @@ -1,9 +1,9 @@ # pyre-unsafe from testslide.core.lib import ( - _extract_NonCallableMock_template, - CoroutineValueError, + _extract_NonCallableMock_template, # noqa + CoroutineValueError, # noqa TypeCheckError, - WrappedMock, + WrappedMock, # noqa ) TypeCheckError = TypeCheckError