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

[feature-request] Special case E721 (use isinstance instead of type comparison) for type(None) #1056

Closed
smackesey opened this issue Dec 5, 2022 · 0 comments · Fixed by #1356

Comments

@smackesey
Copy link

smackesey commented Dec 5, 2022

Comparison to type(None) occasionally comes up in our codebase:

if context.dagster_type.typing_type == type(None):
    return None

This raises a ruff/flake8 error: E721 Do not compare types, use isinstance().

IMO this rule should not apply for comparisons to type(None), since the "correct" form implied by the rule looks very odd:

if isinstance(None, context.dagster_type.typing_type):
    return None

I think this weirdness is unique to type(None).

@smackesey smackesey changed the title Special case E721 for type(None) Special case E721 (use isinstance instead of type comparison) for type(None) Dec 5, 2022
@smackesey smackesey changed the title Special case E721 (use isinstance instead of type comparison) for type(None) [feature-request] Special case E721 (use isinstance instead of type comparison) for type(None) Dec 5, 2022
squiddy added a commit to squiddy/ruff that referenced this issue Dec 24, 2022
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.

2 participants