nodejs / gyp-next

A fork of the GYP build system for use in the Node.js projects
BSD 3-Clause "New" or "Revised" License
130 stars 73 forks source link

fix: fix E721 lint errors #206

Closed rzhao271 closed 3 months ago

rzhao271 commented 1 year ago

% 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