-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Pivot to using ruff for all linting #15603
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
Changes from 9 commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
4aaf383
Pivot to using ruff for all linting
mtreinish 15d6c0f
Remove out of date comment
mtreinish d4f417b
Update makefile
mtreinish dae8132
Enable more rules
mtreinish a9ecb8b
Revert lambda autofixes
mtreinish 4daba2f
Fix new rules
mtreinish d6bef4f
Add bandit rules
mtreinish 9cef8e3
Enable Ruff native rules
mtreinish 0dd82d8
Remove pylint disable comments
mtreinish 4f1bc26
Merge remote-tracking branch 'origin/main' into use-ruff
mtreinish f928646
Enable docstring rules
mtreinish b0ea4d8
Add categories from old ruff config
mtreinish 3b74a92
Merge remote-tracking branch 'origin/main' into use-ruff
mtreinish a05a972
Fix from rebase
mtreinish 6cf6eac
Add flake8-raise rule
mtreinish e96963b
Add flake8-pie rules
mtreinish 69c293f
Add implicit namespace rules
mtreinish 2cb1d4f
Fix deprecation decorator error on import
mtreinish cb31f8c
Merge branch 'main' into use-ruff
mtreinish b47daf1
Fix __init__ docstring for deprecated circuit library elements
mtreinish eebef5e
Revert "Enable docstring rules"
mtreinish 8be7920
Fix typo in latex circuit drawer changes
mtreinish 9b71afe
Fix csp tests for rng change
mtreinish c310f9c
Merge remote-tracking branch 'origin/main' into use-ruff
mtreinish 78dda2b
Remove unused typing imports
mtreinish b6610f5
Merge remote-tracking branch 'origin/main' into use-ruff
mtreinish f8d2c4e
Bump to ruff 0.15.2
mtreinish 6c3b56f
Merge remote-tracking branch 'origin/main' into use-ruff
mtreinish 16e4595
Merge remote-tracking branch 'origin/main' into use-ruff
mtreinish File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
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 |
|---|---|---|
|
|
@@ -221,18 +221,62 @@ test-command = "cp -r {project}/test . && stestr --test-path test/python run --a | |
| repair-wheel-command = "cp {wheel} {dest_dir}/. && pipx run abi3audit --strict --report {wheel}" | ||
|
|
||
| [tool.ruff] | ||
| line-length = 110 | ||
|
|
||
| [tool.ruff.lint] | ||
| select = [ | ||
| # Rules in alphabetic order | ||
| "C4", # category: flake8-comprehensions | ||
| "EXE", # Category: flake8-executable | ||
| "F631", # assert-tuple | ||
| "F632", # is-literal | ||
| "F634", # if-tuple | ||
| "F823", # undefined-local | ||
| "G", # flake8-logging-format | ||
| "T10", # category: flake8-debugger | ||
| # pycodestyle | ||
| "E", | ||
| # Pyflakes | ||
| "F", | ||
| # Pylint | ||
| "PL", | ||
| # pyupgrade | ||
| "UP", | ||
| # bandit | ||
| "S", | ||
| # Ruff native rules | ||
| "RUF", | ||
| ] | ||
| ignore = [ | ||
| "E402", # module-import-not-at-top-of-file false positives with module docs | ||
| "F401", # unused-import false triggers on init re-exports with __all__ | ||
| "E501", # line-too-long rely on black for formatting | ||
| "PLR2004", # magic-value-comparison overly pedantic especially in tests | ||
| "PLR0911", # too-many-return-statements | ||
| "PLR0912", # too-many-branches | ||
| "PLR0904", # too-many-public-methods | ||
| "PLR0914", # too-many-locals | ||
| "PLR0915", # too-many-statements | ||
| "PLR1702", # too-many-nested-blocks | ||
| "PLR0904", # too-many-public-methods | ||
| "PLC0415", # import-outside-top-level | ||
| "E731", # lambda-assignment | ||
| "PLW1514", # unspecified-encoding do not want to implement | ||
| "PLR0913", # too-many-arguments | ||
| "PLW1641", # eq-without-hash not everything has to be hashablie | ||
| "PLW3301", # nested-min-max | ||
| "PLW2901", # redefined-loop-variablke - TODO fix this | ||
| "RUF003", # ambiguous-unicode-character-comment | ||
| "RUF005", # collection-literal-concatenation | ||
| "RUF012", # mutable-class-default" | ||
| "RUF001", # ambiguous-unicode-character-string | ||
| "RUF002", # ambiguous-unicode-character-docstring | ||
| "RUF007", # zip-instead-of-pairwise overly opinionated | ||
| ] | ||
|
|
||
| [tool.ruff.lint.per-file-ignores] | ||
| "*.ipynb" = ["F821"] | ||
| # Security rules from bandit don't apply to tests and utils | ||
| "tools/*" = ["S603"] | ||
| "test/*" = ["S110", "S301", "S603", "S311", "S307", "RUF015"] | ||
| "test/randomized/*" = ["S101"] | ||
| "test/qpy_compat/*" = ["S101"] | ||
| "test/benchmarks/*" = ["S101"] | ||
| # Visualization functions often subprocess to visualization tools | ||
| "qiskit/visualization/*" = ["S603", "S607"] | ||
|
|
||
|
|
||
| [tool.pylint.main] | ||
| extension-pkg-allow-list = [ | ||
|
Comment on lines
488
to
489
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the entire
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I opened a PR for this in: #15717 |
||
| "numpy", | ||
|
|
@@ -263,22 +307,19 @@ disable = [ | |
| "protected-access", # disabled as we don't follow the public vs private convention strictly | ||
| "duplicate-code", # disabled as it is too verbose | ||
| "redundant-returns-doc", # for @abstractmethod, it cannot interpret "pass" | ||
| "too-many-lines", "too-many-branches", "too-many-locals", "too-many-nested-blocks", "too-many-statements", | ||
| "too-many-instance-attributes", "too-many-arguments", "too-many-public-methods", "too-few-public-methods", "too-many-ancestors", | ||
| "too-many-instance-attributes", "too-many-arguments", "too-few-public-methods", "too-many-ancestors", | ||
| "unnecessary-pass", # allow for methods with just "pass", for clarity | ||
| "unnecessary-dunder-call", # do not want to implement | ||
| "no-else-return", # relax "elif" after a clause with a return | ||
| "docstring-first-line-empty", # relax docstring style | ||
| "import-outside-toplevel", "import-error", # overzealous with our optionals/dynamic packages | ||
| "nested-min-max", # this gives false equivalencies if implemented for the current lint version | ||
| "consider-using-max-builtin", "consider-using-min-builtin", # unnecessary stylistic opinion | ||
| # TODO(#9614): these were added in modern Pylint. Decide if we want to enable them. If so, | ||
| # remove from here and fix the issues. Else, move it above this section and add a comment | ||
| # with the rationale | ||
| "no-member", # for dynamically created members | ||
| "not-context-manager", | ||
| "unnecessary-lambda-assignment", # do not want to implement | ||
| "unspecified-encoding", # do not want to implement | ||
| ] | ||
|
|
||
| enable = [ | ||
|
|
||
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
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.
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.
Uh oh!
There was an error while loading. Please reload this page.