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

False positives in 0.1.12 with RUF011 #9487

Closed
pablogamboa opened this issue Jan 12, 2024 · 1 comment · Fixed by #9494
Closed

False positives in 0.1.12 with RUF011 #9487

pablogamboa opened this issue Jan 12, 2024 · 1 comment · Fixed by #9494
Assignees
Labels
bug Something isn't working

Comments

@pablogamboa
Copy link

ruff: 0.1.12
invokation: ruff foobar.py
settings:

[tool.ruff]
line-length = 120
select = ["B", "C4", "D", "E", "F", "G", "I", "INP", "ISC", "N", "T20", "PIE", "PT", "RUF", "SIM", "UP", "W"]
ignore = [
  "B008",  # Do not perform function call {name} in argument defaults
  "B017",  # {assertion}({exception}) should be considered evil
  "B904",  # Within an except clause, raise exceptions with raise ... from err or raise ... from None to distinguish the
m from errors in exception handling
  "D100",  # Missing docstring in public module
  "D101",  # Missing docstring in public class
  "D102",  # Missing docstring in public method
  "D103",  # Missing docstring in public function
  "D104",  # Missing docstring in public package
  "D105",  # Missing docstring in magic method
  "D106",  # Missing docstring in public nested class
  "D107",  # Missing docstring in __init__
  "D205",  # 1 blank line required between summary line and description
  "D415",  # First line should end with a period, question mark, or exclamation point
  "E501",  # Line too long
  "ISC001", # Single line implicit string concatenation (disabled as conflicts with ruff's formatter)
  "PT004", # Fixture does not return anything, add leading underscore
  "PT011", # pytest.raises({exception}) is too broad, set the match parameter or use a more specific exception
  "PT018", # Assertion should be broken down into multiple parts
  "PT019", # Fixture {name} without value is injected as parameter, use @pytest.mark.usefixtures instead
  "RUF005", # Consider {expr} instead of concatenation
  "RUF012", # Mutable class attributes should be annotated with `typing.ClassVar`
  "RUF015", # Prefer `next(...)` over single element slice
  "SIM102", # Use a single `if` statement instead of nested `if` statements
  "SIM108", # Use ternary operator instead of `if`-`else`-block
  "SIM114", # Combine `if` branches using logical `or` operator
  "SIM117", # Use a single `with` statement with multiple contexts instead of nested `with` statements
  "N805",   # First argument of a method should be named `self`
]

fixable = ["B", "C4", "D", "E", "F", "I", "N", "PIE", "PT", "RUF", "SIM", "UP"]
unfixable = []

snippet:

def _extract_local_id(foo):
    return foo


tokens = {"a": "b"}
tokens = {local_id: token for token in tokens if (local_id := _extract_local_id(token)) is not None}

output:

foobar.py:6:11: RUF011 Dictionary comprehension uses static key: `local_id`
Found 1 error.
@charliermarsh charliermarsh added the bug Something isn't working label Jan 12, 2024
@charliermarsh
Copy link
Member

Oops, thanks -- will fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants