-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
STYLE loosen inconsistent namespace check #40532
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
STYLE loosen inconsistent namespace check #40532
Conversation
c211695
to
a5e0d1f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice @MarcoGorelli. Was this check still running only for tests? If so maybe it could be extended to ordinary source files too (although it seems that tests are where most of the violations tend to be)?
self.pandas_namespace: MutableMapping[Offset, str] = {} | ||
self.no_namespace: Set[str] = set() | ||
self.pandas_namespace: MutableMapping[OffsetWithNamespace, str] = {} | ||
self.imported_from_pandas: Set[str] = set() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Outside scope of the PR of course, but curious how hard it would be to generalize this to any namespace? Then you could see it being a helpful linting check even outside of pandas.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a great idea, thanks! Added to my backlog
…nt-namespace-check
can you merge master; i think the docbuild should be fixed (not sure about the other one) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm. @jorisvandenbossche if any comments
@MarcoGorelli can you merge master and ping on greenish |
…nt-namespace-check
…nt-namespace-check
@MarcoGorelli if you an merge master once more |
…nt-namespace-check
@jreback sure, done |
thanks @MarcoGorelli |
For context, see #40468, where the error which was fixed was arguably a false-positive.
I've loosened the check so that now it only errors / replaces if:
e.g. from pandas.io.formats import info
pd.
orpandas.
(e.g.pd.info
orpandas.info
)Before, it just checked whether an object appeared both with and without the
pd.
prefix, which was too tight a check - sorry about that 😳I've also added line number and column offset of the inconsistency for ease of checking/fixing