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

fix: fix E721 lint errors #206

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

rzhao271
Copy link
Contributor

@rzhao271 rzhao271 commented Aug 27, 2023

% ruff rule E721

type-comparison (E721)

Derived from the pycodestyle linter.

What it does

Checks for object type comparisons without using isinstance().

Why is this bad?

Do not compare types directly.

When checking if an object is a instance of a certain type, keep in mind
that it might be subclassed. For example, bool inherits from int, and
Exception inherits from BaseException.

Example

if type(obj) is type(1):
    pass

if type(obj) is int:
    pass

Use instead:

if isinstance(obj, int):
    pass

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 this pull request may close these issues.

None yet

1 participant