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

SIM911 false positive (with bad autofix) on non-zip attribute calls #11125

Closed
lukas-folle-snkeos opened this issue Apr 24, 2024 · 1 comment · Fixed by #11126
Closed

SIM911 false positive (with bad autofix) on non-zip attribute calls #11125

lukas-folle-snkeos opened this issue Apr 24, 2024 · 1 comment · Fixed by #11126
Assignees
Labels
bug Something isn't working

Comments

@lukas-folle-snkeos
Copy link

Description

Running the ruff format on plt.bar(dict_a.keys(), dict_a.values()) is formatted by ruff to dict_a.items() which seems to be an issue.

This is the pre-commit config I am using

- repo:
https://github.com/astral-sh/ruff-pre-commit
  rev: 21d9bff1d62aaf03230baa6b804b9074255fa9b8 # v0.4.1
  hooks:
    - id: ruff
      args:
        - --output-format
        - full
        - --fix
      types_or: [python, pyi, jupyter]
    - id: ruff-format
      types_or: [python, pyi, jupyter]

Example

from matplotlib.pyplot import plt

dict_a = {"A":1, "B":2, "C":3}

plt.bar(dict_a.keys(), dict_a.values())

Resolves this to:

dict_a = {"A": 1, "B": 2, "C": 3}

dict_a.items()
@charliermarsh charliermarsh self-assigned this Apr 24, 2024
@charliermarsh charliermarsh added the bug Something isn't working label Apr 24, 2024
@charliermarsh
Copy link
Member

Thanks, will fix this now!

@AlexWaygood AlexWaygood changed the title [Bug] Ruff format strange behaviour on matplotlib.bar SIM911 false positive (with bad autofix) on non-zip attribute calls Apr 24, 2024
charliermarsh added a commit that referenced this issue Apr 24, 2024
…lls (#11126)

## Summary

The `matches!` macro here is slightly off and allows _all_ attribute
calls through.

Closes #11125.
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