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

E721 and memoryview #8483

Closed
hauntsaninja opened this issue Nov 3, 2023 · 0 comments · Fixed by #8485
Closed

E721 and memoryview #8483

hauntsaninja opened this issue Nov 3, 2023 · 0 comments · Fixed by #8485

Comments

@hauntsaninja
Copy link
Contributor

λ cat x.py
def f(t):
    if t == str:
        pass
    elif t == bytes:
        pass
    elif t == memoryview:
        pass
λ ruff check --select=E721 x.py
x.py:2:8: E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks
x.py:4:10: E721 Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks
Found 2 errors.

ruff should complain about comparison with memoryview as well

charliermarsh pushed a commit that referenced this issue Nov 4, 2023
## Summary

Adds `memoryview` to the list of typeclasses that `fn is_type()` uses
for type comparison checks so that it raises a violation if `is`, `is
not` or `isinstance()` are not used.

## Test Plan

Added examples to existing fixture

## Issue Link

Closes: #8483
hauntsaninja added a commit to hauntsaninja/ruff that referenced this issue Nov 5, 2023
See astral-sh#8483. Generalised fix on top of astral-sh#8485

Based on the output of `print("\n".join(k for k, v in
builtins.__dict__.items() if isinstance(v, type)))`
charliermarsh pushed a commit that referenced this issue Nov 6, 2023
See #8483. Generalised fix on top of #8485

Based on the output of `print("\n".join(k for k, v in
builtins.__dict__.items() if isinstance(v, type)))`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant