-
Notifications
You must be signed in to change notification settings - Fork 751
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: Naive for modules named types
#830
Comments
@froody: is this fixed and deployed in a recent release? |
@coxley no, the PR which mentioned this was closed without merge |
Ah whoops, missed that. Thanks. |
Ping ping ping. We run into so many false-positives with this. Considering disabling the lint globally in our setup, but it's a nice one to have. |
@coxley please don't ping issues like that, I'd suggest attempting a patch |
I've got the same issue in one of my modules, importing a local Update: got it! the COMPARE_TYPE_REGEX pattern is quite complicated (needlessly?) and matches things that go |
Any `types.*Type*` matches incorrectly as a `type(...)` comparison; the regex `COMPARE_TYPE_REGEX` seems a bit too complicated for what should be a simple comparison case. Ref: https://github.com/PyCQA/pycodestyle/blob/main/pycodestyle.py#L147-L148 This reproduces the case in PyCQA#830
This relates to #671
Install Method and Version
Context
E721 is the error for comparing the
type(x)
of something with another instead of usingisinstance
. Looking at #671, I thought this was something that I could submit a PR for. Looking at the testsuite for E72, however, this is expected behavior currently.Problem
Any object named
types
is assumed to be the stdlibtypes
module. There are many just reasons for a library to have atypes
module making selective disabling of E721 mandatory. (or alias imports).Submitting an issue instead of PR because I'm not sure what context can be available to checks. :) The goal of the project is to be quick so the
ast
is out of the question. With that, either:types
module checkingtypes
The text was updated successfully, but these errors were encountered: