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

[python][tests] unused and missing imports #3023

Merged
merged 1 commit into from
Apr 25, 2020

Conversation

jameslamb
Copy link
Collaborator

Just out of curiosity, I ran this on the codebase tonight:

flake8 --exclude=E501,W503

This PR fixes these warnings from it

./tests/python_package_test/test_engine.py:1860:9: F841 local variable 'iter_min' is assigned to but never used
./tests/python_package_test/test_sklearn.py:304:21: F821 undefined name 'warnings'
./tests/c_api_test/test_.py:4:1: F401 'sys' imported but unused

A couple other warnings are generated but I think they should be ignored. Some thing in outt tests look like "local variable never used" but they're things like this where even if we don't test the value, generating acts as a smoke test:

model = lgb.train(default_params, lgb_train, valid_sets=[lgb_val])

Here is the full log if you're curious:

flake8 logs
./tests/python_package_test/test_engine.py:924:9: F841 local variable 'gbm' is assigned to but never used
./tests/python_package_test/test_engine.py:1024:13: F841 local variable 'gbm' is assigned to but never used
./tests/python_package_test/test_engine.py:1860:9: F841 local variable 'iter_min' is assigned to but never used
./tests/python_package_test/test_engine.py:2102:9: F841 local variable 'model' is assigned to but never used
./tests/python_package_test/test_plotting.py:149:9: F841 local variable 'gbm0' is assigned to but never used
./tests/python_package_test/test_plotting.py:164:9: F841 local variable 'gbm1' is assigned to but never used
./tests/python_package_test/test_sklearn.py:193:9: F841 local variable 'gbm_clone' is assigned to but never used
./tests/python_package_test/test_sklearn.py:304:21: F821 undefined name 'warnings'
./tests/c_api_test/test_.py:4:1: F401 'sys' imported but unused
./python-package/lightgbm/compat.py:28:5: F401 'itertools.izip as zip_' imported but unused
./python-package/lightgbm/compat.py:29:19: F821 undefined name 'basestring'
./python-package/lightgbm/compat.py:30:27: F821 undefined name 'long'
./python-package/lightgbm/compat.py:31:27: F821 undefined name 'long'
./python-package/lightgbm/compat.py:32:14: F821 undefined name 'xrange'
./python-package/lightgbm/compat.py:48:5: F401 'json' imported but unused
./python-package/lightgbm/compat.py:83:5: F401 'matplotlib' imported but unused
./python-package/lightgbm/compat.py:90:5: F401 'graphviz' imported but unused

Copy link
Collaborator

@StrikerRUS StrikerRUS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, LGTM!

@StrikerRUS StrikerRUS changed the title [python] unused and missing imports [python][tests] unused and missing imports Apr 25, 2020
@StrikerRUS StrikerRUS merged commit eedc1a7 into microsoft:master Apr 25, 2020
@jameslamb jameslamb deleted the misc/flake8 branch April 25, 2020 17:02
@lock lock bot locked as resolved and limited conversation to collaborators Jun 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants