Repository navigation
Add ruff to pre-commit - #581
Merged
Merged
Conversation
Enable ruff's classic default rules (E4, E7, E9, F) plus import sorting (I) and syntax upgrades (UP).
Ruff removed the sys.version_info branches for Python < 3.8, which left both subprocess_run_3_9 helpers unused. They were already broken (TimeoutExpired was never imported), so remove them along with the msvcrt/_mswindows probe that only they used. Also convert the remaining "# type: Dict[...]" comments to annotations so the deprecated typing.Dict/List imports can go.
Hand fixes for what ruff cannot fix safely: - type(x) == T -> type(x) is T, == None -> is None - bare except -> except OSError/Exception - drop unused locals, a duplicated "generic" dict key and two no-op .format() calls - move stray module-level imports to the top - rename ambiguous `l` loop variables Add FIXME comments for five existing bugs that ruff surfaced, in vcs.py, tools/xcelium.py, design_compiler.py, openfpga.py and scripts/el_docker, to be fixed separately.
Test modules imported make_edalize_test, tool_fixture and flow_fixture and then took them as parameters of the same name, which ruff reports as unused (F401) and redefined (F811). Register the fixture modules with pytest_plugins in tests/conftest.py and drop the imports.
This includes the extensionless scripts in tests/mock_commands, which the ruff pre-commit hook also checks. The imports in test_plugin.py are what the test checks, so they keep a noqa. The vunit mock re-exports VUnit with a redundant alias.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Adds a ruff check hook to pre-commit and fixes everything it reports. The rules are ruff's classic defaults (E4, E7, E9, F) plus isort (I) and pyupgrade (UP). They are listed explicitly in pyproject.toml so that a ruff upgrade that changes its defaults doesn't change ours.
Ruff surfaced five existing bugs in vcs.py, tools/xcelium.py, design_compiler.py, openfpga.py and scripts/el_docker. Fixing them changes behavior, so they are marked with FIXME comments and left for separate PRs.
Testing: pre-commit run -a is clean and all 239 tests pass locally on Python 3.14.