Skip to content

Various style improvements #2049

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
merged 3 commits into from
Jun 8, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update Ruff configuration
This resolves two warnings about Ruff configuration, by:

- No longer setting `ignore-init-module-imports = true` explicitly,
  which was deprecated since `ruff` 0.4.4. We primarily use `ruff`
  via `pre-commit`, for which this deprecation has applied since we
  upgraded the version in `.pre-commit-config.yaml` from 0.4.3 to
  0.6.0 in d1582d1 (#1953).

  We continue to list `F401` ("Module imported but unused") as not
  automatically fixable, to avoid inadvertently removing imports
  that may be needed.

  See also:
  https://docs.astral.sh/ruff/settings/#lint_ignore-init-module-imports

- Rename the rule `TCH004` to `TC004`, since `TCH004` is the old
  name that may eventually be removed and that is deprecated since
  0.8.0. We upgraded `ruff` in `.pre-commit-config.yml` again in
  b7ce712 (#2031), from 0.6.0 to 0.11.12, at which point this
  deprecation applied.

  See also https://astral.sh/blog/ruff-v0.8.0.

These changes make those configuration-related warnings go away,
and no new diagnostics (errors/warnings) are produced when running
`ruff check` or `pre-commit run --all-files`. No F401-related
diagnostics are triggered when testing with explicit
`ignore-init-module-imports = false`, in preview mode or otherwise.

In addition, this commit makes two changes that are not needed to
resolve warnings:

- Stop excluding `E203` ("Whitespace before ':'"). That diagnostic
  is no longer failing with the current code here in the current
  version of `ruff`, and code changes that would cause it to fail
  would likely be accidentally mis-st

- Add the version lower bound `>=0.8` for `ruff` in
  `requirements-dev.txt`. That file is rarely used, as noted in
  a8a73ff (#1871), but as long as we have it, there may be a
  benefit to excluding dependency versions for which our
  configuration is no longer compatible. This is the only change in
  this commit outside of `pyproject.toml`.
  • Loading branch information
EliahKagan committed Jun 8, 2025
commit 6f4f7f5137d63facb61eae2955e6c0801c71b7b5
10 changes: 4 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,14 @@ lint.select = [
# "UP", # See: https://docs.astral.sh/ruff/rules/#pyupgrade-up
]
lint.extend-select = [
# "A", # See: https://pypi.org/project/flake8-builtins
"B", # See: https://pypi.org/project/flake8-bugbear
"C4", # See: https://pypi.org/project/flake8-comprehensions
"TCH004", # See: https://docs.astral.sh/ruff/rules/runtime-import-in-type-checking-block/
# "A", # See: https://pypi.org/project/flake8-builtins
"B", # See: https://pypi.org/project/flake8-bugbear
"C4", # See: https://pypi.org/project/flake8-comprehensions
"TC004", # See: https://docs.astral.sh/ruff/rules/runtime-import-in-type-checking-block/
]
lint.ignore = [
"E203", # Whitespace before ':'
"E731", # Do not assign a `lambda` expression, use a `def`
]
lint.ignore-init-module-imports = true
lint.unfixable = [
"F401", # Module imported but unused
]
Expand Down
2 changes: 1 addition & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
-r test-requirements.txt

# For additional local testing/linting - to be added elsewhere eventually.
ruff
ruff >=0.8
shellcheck
pytest-icdiff
# pytest-profiling
Loading