-
Notifications
You must be signed in to change notification settings - Fork 19
Select and comply with all Ruff rules, minus a curated ignore list #290
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
Merged
seddonym
merged 12 commits into
python-grimp:main
from
nathanjmcdougall:refactor/enable-strict-ruff-config
Dec 22, 2025
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
5588928
Select and comply with all Ruff rules, minus a curated ignore list
nathanjmcdougall c390810
Remove hyphens from docstring
nathanjmcdougall ed6dbd7
Improve docstring format for `find_illegal_dependencies_for_layers`
nathanjmcdougall f5a681e
Migrate config to `ruff.toml` and add comments regarding the reasons …
nathanjmcdougall 8796027
Merge remote-tracking branch 'upstream/main' into refactor/enable-str…
nathanjmcdougall 716b13b
Ignore `S101` rule and revert associated changes
nathanjmcdougall 44ee64d
Use exception chaining in some cases, use consistent naming `e` -> `exc`
nathanjmcdougall f36e56f
Disable `PYI025` rule and revert aliasing i.e. `AbstractSet` -> `Set`
nathanjmcdougall 842ab5e
Revert TC001, TC002, TC003 rule compliance (TYPE_CHECKING guards)
nathanjmcdougall a181106
Add `match` arg in `pytest.warns` for `DeprecationWarning` of `Names…
nathanjmcdougall 76c1335
Merge branch 'fix/comply-with-ruff-rule-for-namespace-deprec' into re…
nathanjmcdougall 2681042
Merge branch 'main' into refactor/enable-strict-ruff-config
nathanjmcdougall File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| line-length = 99 | ||
| exclude = [ | ||
| 'tests/assets', # These are sample packages for tests to run under - we don't want ruff to mess with them. | ||
| 'docs/', # Documentation configuration scripts | ||
| ] | ||
| lint.select = [ "ALL" ] | ||
| lint.ignore = [ | ||
| "A005", # [stdlib-module-shadowing] Backward Compat. Violated by `modulefinder.py`. | ||
| "ANN401", # [any-type] Controversial. We use `Any` type annotations in several places intentionally. | ||
| "ARG002", # [unused-method-argument] Backward Compat. | ||
| "C408", # [unnecessary-collection-call] Controversial. A micro-optimization like `dict(a=1)` -> `{"a": 1}` that hurts readability. | ||
| "COM812", # [missing-trailing-comma] TODO enable. Has a large diff to fix all occurrences. | ||
| "D1", # [pydocstyle : Undocumented] TODO enable. Not a priority to have every public interface documented yet. | ||
| "D2", # [pydocstyle : Whitespace issues] TODO enable. Has a large diff to fix all occurrences. | ||
| "E501", # [line-too-long] Controversial. Long comments and docstrings are sometimes clearer. The formatter already addresses most violations. | ||
| "FBT", # [flake8-boolean-trap] Backward Compat. | ||
| "FIX", # [flake8-fixme] Controversial. Different projects use different conventions for FIXME/TODO comments. | ||
| "G004", # [logging-f-string] Controversial. A micro-optimization but hurts readability. | ||
| "N818", # [error-suffix-on-exception-name] Backward Compat. | ||
| "PERF203", # [try-except-in-loop] Controversial. A micro-optimization but increases code complexity. | ||
| "PLR0913", # [too-many-arguments] Backward Compat. | ||
| "PLW1641", # [eq-without-hash] TODO enable. This is low-priority, and basically an enhancement to make classes more ergonomic. | ||
| "PTH", # [flake8-use-pathlib] Controversial. `pathlib` adoption is subtle and might be too disruptive for this codebase. e.g. https://github.com/python-grimp/grimp/pull/289#discussion_r2636012008 | ||
| "PT007", # [pytest-parametrize-values-wrong-type] TODO enable. Inconsistent use of `@pytest.mark.parametrize("value", ("a", "b", "c"))` versus `...["a", "b", "c"])` in parameterizations. | ||
| "PYI025", # [unaliased-collections-abc-set-import] Controversial. `collections.abc.Set` is not necessarily confused with the built-in `set`. | ||
| "RET504", # [unnecessary-assign] Controversial. A micro-optimization but hurts readability. | ||
| "RET505", # [superfluous-else-return] Controversial. Explicit `else` blocks can improve readability. | ||
| "S101", # [assert] Controversial. `assert` statements are sometimes appropriate for type-checking purposes. | ||
| "SIM108", # [if-else-block-instead-of-if-exp] Controversial. Ternary/Binary in-line expressions often hurt readability. | ||
| "SIM118", # [in-dict-keys] Controversial. `if key in dict.keys()` sometimes has clearer intent than `if key in dict`. | ||
| "TC001", # [typing-only-first-party-import] Controversial. This package has no/few dependencies so TYPE_CHECKING guards offer no material benefit and hurt readability. | ||
| "TC002", # [typing-only-third-party-import] Controversial. This package has no/few dependencies so TYPE_CHECKING guards offer no material benefit and hurt readability. | ||
| "TC003", # [typing-only-standard-library-import] Controversial. This package has no/few dependencies so TYPE_CHECKING guards offer no material benefit and hurt readability. | ||
| "TD", # [missing-space-after-todo-colon] Controversial. Different projects use different conventions for FIXME/TODO comments. | ||
| "TID252", # [relative-imports] Controversial. There are pros and cons to both relative and absolute imports in a packaging context. | ||
| ] | ||
| lint.per-file-ignores."tests/**/*.py" = [ | ||
| "ANN", # [flake8-annotations] Type annotations not needed in a test suite | ||
| "ARG", # [flake8-unused-arguments] Interface design doesn't need attention in a test suite | ||
| "B007", # [unused-loop-control-variable] Unused variables are common in tests | ||
| "B018", # [useless-expression] Unused variables are common in tests | ||
| "B033", # [duplicate-value] Can be deliberate in a test suite | ||
| "D", # [pydocstyle] Docstrings not needed in a test suite | ||
| "EM", # [flake8-errmsg] Error message style doesn't need attention in a test suite | ||
| "N806", # [non-lowercase-variable-in-function] Variable naming conventions don't need attention in a test suite | ||
| "PLR2004", # [magic-value-comparison] Magic values are common in tests | ||
| "RUF012", # [mutable-class-default] Type annotations not needed in a test suite | ||
| "RUF059", # [unused-unpacked-variable] Unused variables are common in tests | ||
| "S", # [flake8-bandit] Security patterns don't need attention in a test suite | ||
| "SIM300", # [yoda-conditions] TODO enable. | ||
| "TRY", # [tryceratops] Exception handling patterns don't need attention in a test suite | ||
| ] | ||
| lint.pydocstyle.convention = "google" | ||
| lint.future-annotations = true | ||
| lint.flake8-builtins.strict-checking = true | ||
| lint.flake8-pytest-style.parametrize-names-type = "csv" | ||
| lint.flake8-type-checking.quote-annotations = true | ||
| lint.typing-extensions = false | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Going the extra mile with all these comments! 👏🏻
I may edit some of them in a subsequent PR as I don't agree with everything here but it's a really useful first cut.