Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: adopt ruff as a linter #7

Merged
merged 2 commits into from
Jan 8, 2024
Merged

Conversation

AlessandroMiola
Copy link
Owner

@AlessandroMiola AlessandroMiola commented Jan 8, 2024

Summary:

  • c0179d3:
    • pyproject.toml: add configuration for ruff linter 1 2
    • .pre-commit-config.yaml: add pre-commit hook for ruff (while removing flake8's one) 3
    • .github/workflows/actions.yaml: setup action for ruff linter (while removing flake8's one)
    • leftover: apply ruff and black proposed fixes
  • f785b9e:
    • poetry.lock, pyproject.toml, setup.cfg: remove flake8 dependency
    • pyproject.toml: fixable = ["ALL"] is redundant 4
    • README.md: update README as a consequence of enforcing the use of ruff over flake8

Footnotes

  1. better nest linter-specific configs under [tool.ruff.lint], formatter-specific configs under [tool.ruff.format] and configs common to both linter and formatter under [tool.ruff] (see https://github.com/astral-sh/ruff/discussions/9406)

  2. note that

    • ruff's autofix feature is available for most of the lint rules, but not for all of them (eg an autofix for A001 is not available, as I could experience); list of available autofixes at https://docs.astral.sh/ruff/linter/#fix-safety
    • ruff's autofix feature does not apply to unsafe fixes (eg C414, as I could experience); you'd need to promote unsafe fixes to safe by specifying eg extend-safe-fixes = ["C414"] under [tool.ruff.lint] (see https://docs.astral.sh/ruff/linter/#fix-safety) or proceed manually
  3. be aware of putting ruff's linter hook before any formatter hook (black here) as ruff's --fix might apply changes requiring reformatting, which indeed happened (see https://docs.astral.sh/ruff/integrations/#pre-commit)

  4. fixable = ["ALL"] is the default already. Better configure such option in order to specify the (sub)-list of selected (i.e. specified in select =) rules that you would not only check against but also autofix (provided that an autofix is available for them and is safe); indeed, there might be rules you would check against, but manually (and not automatically) fix

Copy link

codecov bot commented Jan 8, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (2e2ff0c) 100.00% compared to head (f785b9e) 100.00%.

Additional details and impacted files
@@            Coverage Diff            @@
##              main        #7   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           12        12           
  Lines          220       220           
=========================================
  Hits           220       220           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@AlessandroMiola AlessandroMiola merged commit e46113b into main Jan 8, 2024
6 checks passed
@AlessandroMiola AlessandroMiola deleted the adopt_ruff_as_linter branch January 8, 2024 19:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant