Skip to content

Commit

Permalink
ci: replace flake8 with ruff (#917)
Browse files Browse the repository at this point in the history
* ci: replace flake8 with ruff

* fix violations

* update lock file
  • Loading branch information
epenet authored Nov 12, 2024
1 parent e337c88 commit 7dbd7cf
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 133 deletions.
3 changes: 0 additions & 3 deletions .flake8

This file was deleted.

119 changes: 1 addition & 118 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,6 @@ pytest-xdist = '^3.1.0'
black = '^24.1.0'
mypy = '^1.0.1'
py-githooks = '^1.1.1'
flake8 = '^7.0.0'
flake8-bugbear = '^24.0.0'
flake8-builtins = '^2.1.0'
flake8-comprehensions = '^3.10.1'
twine = '^5.1.1'
semver = '^3.0.0'
setuptools-scm = '^8.0.0'
Expand Down Expand Up @@ -91,6 +87,9 @@ exclude_lines = ['pragma: no-cover', 'if TYPE_CHECKING:', '@abstractmethod']

[tool.ruff.lint]
extend-select = [
"A", # flake8-builtins
"B", # flake8-bugbear
"C4", # flake8-comprehensions
"I", # isort
]

Expand Down
2 changes: 1 addition & 1 deletion src/syrupy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def __import_extension(value: Optional[str]) -> Any:
try:
return import_module_member(value)
except FailedToLoadModuleMember as e:
raise argparse.ArgumentTypeError(e)
raise argparse.ArgumentTypeError(e) from e


def pytest_addoption(parser: Any) -> None:
Expand Down
2 changes: 1 addition & 1 deletion src/syrupy/extensions/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ def _count_leading_whitespace(s: str) -> int:
return len(s) - len(s.lstrip())


class SnapshotReporter(ABC):
class SnapshotReporter:
_context_line_count = 1

def diff_snapshots(
Expand Down
8 changes: 4 additions & 4 deletions src/syrupy/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,20 +54,20 @@ def import_module_member(path: str) -> Any:
)
try:
module = import_module(module_name)
except ModuleNotFoundError:
except ModuleNotFoundError as e:
raise FailedToLoadModuleMember(
gettext("Module '{}' does not exist.").format(module_name)
)
) from e

try:
return getattr(module, module_member_name)
except AttributeError:
except AttributeError as e:
raise FailedToLoadModuleMember(
gettext("Member '{}' not found in module '{}'.").format(
module_member_name,
module_name,
)
)
) from e


def get_env_value(env_var_name: str) -> object:
Expand Down
3 changes: 1 addition & 2 deletions tasks/lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

lint_commands = {
"black": lambda fix: f"python -m black {'' if fix else '--check'} .",
"flake8": lambda _: "python -m flake8 src tests benchmarks *.py",
"mypy": lambda _: "python -m mypy --strict src benchmarks",
"ruff": lambda fix: f"python -m ruff check {'--fix' if fix else ''} .",
}
Expand All @@ -19,7 +18,7 @@ def run_lint(ctx, section, fix):


@task(default=True)
def all(ctx, fix=False):
def all(ctx, fix=False): # noqa: A001
"""
Check and fix syntax using various linters
"""
Expand Down

0 comments on commit 7dbd7cf

Please sign in to comment.