MAINT: Review F401,F841,F842 flake8 errors (unused variables and imports)#12448
MAINT: Review F401,F841,F842 flake8 errors (unused variables and imports)#12448charris merged 5 commits intonumpy:masterfrom
Conversation
| # Regression test for gh-7707. If npymath.ini wasn't installed, then this | ||
| # will give an error. | ||
| info = get_info('npymath') | ||
| get_info('npymath') |
There was a problem hiding this comment.
Would be great to add some basic test of info here, rather than just ignoring the return value
|
Mostly looks good. Thanks for only touching test and private files - note that in many cases we're stuck with unused imports in our public files because those import often accidentally form part of our public API. |
|
Thanks for the review! I addressed your comments, added a few
Yes, it's not an easy problem... |
numpy/distutils/misc_util.py
Outdated
| except AttributeError: | ||
| return False | ||
| # FIXME: below code is never reached | ||
| __NUMPY_SETUP__ = False |
There was a problem hiding this comment.
Ok, I get this now - I think this is supposed to set builtins.__NUMPY_SETUP__.
There was a problem hiding this comment.
Yes, but e.g. numpy/__init__.py handles the existence of builtins.__NUMPY_SETUP__ as true, and the absence of it as false. I removed this, as this line is never reached and I think it's more confusing than it helps.
Also, unless I missed something, this util function doesn't seem to be called in the numpy code in general, and it doesn't really make sense to call it for other packages I think?
There was a problem hiding this comment.
Let's leave it out, it hasn't been missed since 2009.
|
@rth Ping. |
|
Thanks for the reminder @charris . Addressed @eric-wieser 's comments. |
|
Thanks @rth . |
|
Thanks for the review @eric-wieser and @charris ! |
In this PR I run the flake8 on checks corresponding to unused imports and variables,
and selectively removed those I thought should be harmless. For unused variables that looked suspicious, a
FIXMEcomment was added.Unused imports is an issue beyond code style as it makes dependencies between modules harder to understand (not that there much issues with that in numpy -- this PR mostly changes test files).
This should also help with LGTM.com warnings.