Closed
Bug 1059811
Opened 10 years ago
Closed 9 years ago
Fix treeherder-service pyflakes warnings
Categories
(Tree Management :: Treeherder, defect, P3)
Tree Management
Treeherder
Tracking
(Not tracked)
RESOLVED
FIXED
People
(Reporter: emorley, Assigned: emorley)
References
Details
Attachments
(2 files)
Ideally once these are fixed we should get a linter to run during the main Travis run. tests/conftest.py:310: local variable 'job_guid' is assigned to but never used tests/etl/conftest.py:2: 'json' imported but unused tests/etl/conftest.py:5: 'JsonLoaderMixin' imported but unused tests/etl/test_buildbot.py:3: 'datetime' imported but unused tests/etl/test_buildbot.py:4: 'time' imported but unused tests/etl/test_buildbot.py:5: 'json' imported but unused tests/etl/test_buildbot.py:7: 'settings' imported but unused tests/etl/test_buildbot.py:8: redefinition of unused 'buildbot' from line 1 tests/etl/test_perf_data_adapters.py:14: local variable 'ref_data' is assigned to but never used tests/etl/test_perf_data_adapters.py:30: redefinition of unused 'job_data' from line 6 tests/etl/test_perf_data_adapters.py:6: 'job_data' imported but unused tests/etl/test_perf_data_adapters.py:6: 'result_set' imported but unused tests/etl/test_perf_data_adapters.py:7: redefinition of unused 'SampleData' from line 3 tests/etl/test_perf_data_adapters.py:8: 'test_utils' imported but unused tests/log_parser/test_job_artifact_builder.py:1: 'json' imported but unused tests/log_parser/test_job_artifact_builder.py:2: 'diff' imported but unused tests/log_parser/test_log_view_artifact_builder.py:1: 'json' imported but unused tests/log_parser/test_log_view_artifact_builder.py:3: 'diff' imported but unused tests/log_parser/test_tasks.py:5: 'get_mozharness_substring' imported but unused tests/model/derived/sample_data_generator.py:10: 'utils' imported but unused tests/model/derived/test_jobs_model.py:10: 'SampleData' imported but unused tests/model/derived/test_jobs_model.py:4: 'itertools' imported but unused tests/model/derived/test_jobs_model.py:5: 'pprint' imported but unused tests/model/derived/test_objectstore_model.py:136: local variable 'remaining' is assigned to but never used tests/model/derived/test_refdata.py:352: local variable 'time_now' is assigned to but never used tests/sample_data_generator.py:11: 'utils' imported but unused tests/test_setup.py:3: 'Datasource' imported but unused tests/test_utils.py:3: 'AppError' imported but unused tests/webapp/api/test_artifact_api.py:1: 'json' imported but unused tests/webapp/api/test_bug_job_map_api.py:49: local variable 'resp' is assigned to but never used tests/webapp/api/test_jobs_api.py:1: 'json' imported but unused tests/webapp/api/test_resultset_api.py:1: 'pytest' imported but unused tests/webapp/conftest.py:2: 'os' imported but unused treeherder/etl/buildapi.py:10: 'TreeherderRequest' imported but unused treeherder/etl/common.py:1: 'defaultdict' imported but unused treeherder/etl/common.py:8: 'cache' imported but unused treeherder/etl/daemon.py:67: local variable 'e' is assigned to but never used treeherder/etl/management/commands/export_project_credentials.py:7: 'Datasource' imported but unused treeherder/etl/management/commands/export_project_credentials.py:9: 'buildapi' imported but unused treeherder/etl/mixins.py:35: local variable 'e' is assigned to but never used treeherder/etl/perf_data_adapters.py:7: 'ValidationError' imported but unused treeherder/etl/pushlog.py:14: local variable 'result_sets' is assigned to but never used treeherder/etl/pushlog.py:3: 'TreeherderRequest' imported but unused treeherder/etl/tasks.py:4: 'time' imported but unused treeherder/etl/tasks.py:5: 'datetime' imported but unused treeherder/etl/tasks.py:5: 'timedelta' imported but unused treeherder/etl/tasks.py:6: 'cache' imported but unused treeherder/etl/tasks.py:8: 'JobsModel' imported but unused treeherder/etl/tasks.py:9: 'ReferenceDataSignatures' imported but unused treeherder/events/consumer.py:2: 'Connection' imported but unused treeherder/events/consumer.py:2: 'Consumer' imported but unused treeherder/events/consumer.py:31: redefinition of unused 'Consumer' from line 2 treeherder/log_parser/utils.py:4: 'settings' imported but unused treeherder/model/derived/__init__.py:1: 'from base import *' used; unable to detect undefined names treeherder/model/derived/__init__.py:2: 'from refdata import *' used; unable to detect undefined names treeherder/model/derived/__init__.py:3: 'from jobs import *' used; unable to detect undefined names treeherder/model/derived/jobs.py:1555: local variable 'e' is assigned to but never used treeherder/model/derived/jobs.py:2150: local variable 'job_id' is assigned to but never used treeherder/model/derived/jobs.py:2570: local variable 'select_proc' is assigned to but never used treeherder/model/derived/jobs.py:26: 'DataHub' imported but unused treeherder/model/derived/jobs.py:294: local variable 'ex' is assigned to but never used treeherder/model/derived/jobs.py:924: local variable 'where_in_clause' is assigned to but never used treeherder/model/derived/refdata.py:479: local variable 'timestame' is assigned to but never used treeherder/model/management/commands/calculate_eta.py:3: 'Repository' imported but unused treeherder/model/management/commands/calculate_eta.py:4: 'JobsModel' imported but unused treeherder/model/management/commands/cycle_data.py:3: 'Repository' imported but unused treeherder/model/management/commands/cycle_data.py:4: 'JobsModel' imported but unused treeherder/model/management/commands/init_datasources.py:6: 'CommandError' imported but unused treeherder/model/management/commands/load_initial_data.py:3: 'Datasource' imported but unused treeherder/model/management/commands/load_initial_data.py:3: 'Repository' imported but unused treeherder/model/management/commands/populate_performance_series.py:6: 'Repository' imported but unused treeherder/model/management/commands/populate_performance_series.py:7: 'JobsModel' imported but unused treeherder/model/management/commands/publish_result_set_to_pulse.py:3: 'Repository' imported but unused treeherder/model/management/commands/publish_result_set_to_pulse.py:4: 'JobsModel' imported but unused treeherder/model/migrations/0001_initial.py:2: 'datetime' imported but unused treeherder/model/migrations/0001_initial.py:311: redefinition of unused 'models' from line 5 treeherder/model/migrations/0001_initial.py:5: 'models' imported but unused treeherder/model/tasks.py:109: local variable 'data' is assigned to but never used treeherder/model/utils.py:3: 'datetime' imported but unused treeherder/model/utils.py:4: 'sys' imported but unused treeherder/settings/__init__.py:1: 'from base import *' used; unable to detect undefined names treeherder/settings/base.py:246: 'from local import *' used; unable to detect undefined names treeherder/settings/base.py:8: 'crontab' imported but unused treeherder/webapp/admin.py:2: 'from treeherder.model.models import *' used; unable to detect undefined names treeherder/webapp/api/performance_artifact.py:3: 'PerformanceDataAdapter' imported but unused treeherder/webapp/api/performance_artifact.py:4: 'oauth_required' imported but unused treeherder/webapp/api/performance_data.py:1: 'json' imported but unused treeherder/webapp/api/performance_data.py:26: local variable 'e' is assigned to but never used treeherder/webapp/api/performance_data.py:48: local variable 'e' is assigned to but never used treeherder/webapp/api/performance_data.py:5: 'action' imported but unused treeherder/webapp/api/utils.py:166: local variable 'oauth_token' is assigned to but never used treeherder/workers/models.py:1: 'models' imported but unused
Assignee | ||
Updated•9 years ago
|
Assignee: nobody → emorley
Assignee | ||
Comment 1•9 years ago
|
||
I've split this into two commits: one for removing unused imports, the other for removing unused variables. The latter is the one that I'd like you to take a slightly closer look at - in case any of the unused variables actually _should_ be used but aren't due to a bug. (eg There's one case not fixed here, which I'll file a bug for, where I think we're actually doing the wrong thing, so worth double checking the others too). The warnings being fixed are: tests/conftest.py:315: local variable 'job_guid' is assigned to but never used tests/sample_data_generator.py:15: 'utils' imported but unused tests/test_setup.py:7: 'Datasource' imported but unused tests/test_utils.py:7: 'AppError' imported but unused tests/etl/conftest.py:6: 'json' imported but unused tests/etl/conftest.py:9: 'JsonLoaderMixin' imported but unused tests/etl/test_buildbot.py:7: 'datetime' imported but unused tests/etl/test_buildbot.py:8: 'time' imported but unused tests/etl/test_buildbot.py:9: 'json' imported but unused tests/etl/test_buildbot.py:11: 'settings' imported but unused tests/etl/test_buildbot.py:12: redefinition of unused 'buildbot' from line 5 tests/etl/test_perf_data_adapters.py:10: 'job_data' imported but unused tests/etl/test_perf_data_adapters.py:10: 'result_set' imported but unused tests/etl/test_perf_data_adapters.py:11: redefinition of unused 'SampleData' from line 7 tests/etl/test_perf_data_adapters.py:12: 'test_utils' imported but unused tests/etl/test_perf_data_adapters.py:18: local variable 'ref_data' is assigned to but never used tests/etl/test_perf_data_adapters.py:34: redefinition of unused 'job_data' from line 10 tests/etl/test_pushlog.py:9: 'get_not_found_onhold_push' imported but unused tests/log_parser/test_job_artifact_builder.py:5: 'json' imported but unused tests/log_parser/test_job_artifact_builder.py:6: 'diff' imported but unused tests/log_parser/test_log_view_artifact_builder.py:5: 'json' imported but unused tests/log_parser/test_log_view_artifact_builder.py:7: 'diff' imported but unused tests/log_parser/test_performance_artifact_builder.py:5: 'json' imported but unused tests/log_parser/test_performance_artifact_builder.py:6: 'diff' imported but unused tests/log_parser/test_performance_artifact_builder.py:14: 'test_utils' imported but unused tests/model/derived/sample_data_generator.py:14: 'utils' imported but unused tests/model/derived/test_jobs_model.py:8: 'itertools' imported but unused tests/model/derived/test_jobs_model.py:9: 'pprint' imported but unused tests/model/derived/test_jobs_model.py:12: 'settings' imported but unused tests/model/derived/test_jobs_model.py:17: 'SampleData' imported but unused tests/model/derived/test_objectstore_model.py:140: local variable 'remaining' is assigned to but never used tests/model/derived/test_refdata.py:356: local variable 'time_now' is assigned to but never used tests/webapp/conftest.py:6: 'os' imported but unused tests/webapp/api/test_artifact_api.py:5: 'json' imported but unused tests/webapp/api/test_bug_job_map_api.py:53: local variable 'resp' is assigned to but never used tests/webapp/api/test_jobs_api.py:5: 'json' imported but unused tests/webapp/api/test_resultset_api.py:5: 'pytest' imported but unused treeherder/etl/buildapi.py:14: 'TreeherderRequest' imported but unused treeherder/etl/common.py:5: 'defaultdict' imported but unused treeherder/etl/daemon.py:71: local variable 'e' is assigned to but never used treeherder/etl/mixins.py:40: local variable 'e' is assigned to but never used treeherder/etl/perf_data_adapters.py:11: 'ValidationError' imported but unused treeherder/etl/pushlog.py:7: 'time' imported but unused treeherder/etl/pushlog.py:11: 'TreeherderRequest' imported but unused treeherder/etl/pushlog.py:186: local variable 'ex' is assigned to but never used treeherder/etl/management/commands/export_project_credentials.py:11: 'Datasource' imported but unused treeherder/etl/management/commands/export_project_credentials.py:13: 'buildapi' imported but unused treeherder/etl/management/commands/ingest_push.py:8: 'sys' imported but unused treeherder/etl/tasks/buildapi_tasks.py:8: 'group' imported but unused treeherder/etl/tasks/cleanup_tasks.py:8: 'group' imported but unused treeherder/etl/tasks/tasks.py:8: 'group' imported but unused treeherder/events/consumer.py:6: 'Connection' imported but unused treeherder/events/consumer.py:6: 'Consumer' imported but unused treeherder/events/consumer.py:35: redefinition of unused 'Consumer' from line 6 treeherder/log_parser/tasks.py:14: 'get_crash_signature' imported but unused treeherder/log_parser/tasks.py:14: 'get_error_search_term' imported but unused treeherder/log_parser/tasks.py:14: 'get_bugs_for_search_term' imported but unused treeherder/log_parser/tasks.py:14: 'get_mozharness_substring' imported but unused treeherder/model/models.py:12: 'itertools' imported but unused treeherder/model/derived/jobs.py:1561: local variable 'e' is assigned to but never used treeherder/model/management/commands/calculate_eta.py:7: 'Repository' imported but unused treeherder/model/management/commands/calculate_eta.py:8: 'JobsModel' imported but unused treeherder/model/management/commands/init_datasources.py:10: 'CommandError' imported but unused treeherder/model/management/commands/load_initial_data.py:7: 'Repository' imported but unused treeherder/model/management/commands/load_initial_data.py:7: 'Datasource' imported but unused treeherder/model/management/commands/populate_performance_series.py:10: 'Repository' imported but unused treeherder/model/management/commands/populate_performance_series.py:11: 'JobsModel' imported but unused treeherder/model/management/commands/publish_result_set_to_pulse.py:7: 'Repository' imported but unused treeherder/model/management/commands/publish_result_set_to_pulse.py:8: 'JobsModel' imported but unused treeherder/model/migrations/0001_initial.py:6: 'datetime' imported but unused treeherder/model/migrations/0001_initial.py:9: 'models' imported but unused treeherder/model/migrations/0001_initial.py:315: redefinition of unused 'models' from line 9 treeherder/webapp/api/artifact.py:7: 'PerformanceDataAdapter' imported but unused treeherder/webapp/api/jobs.py:7: 'link' imported but unused treeherder/webapp/api/performance_artifact.py:7: 'PerformanceDataAdapter' imported but unused treeherder/webapp/api/performance_artifact.py:8: 'oauth_required' imported but unused treeherder/webapp/api/performance_data.py:5: 'json' imported but unused treeherder/webapp/api/performance_data.py:9: 'action' imported but unused treeherder/webapp/api/performance_data.py:48: local variable 'e' is assigned to but never used treeherder/webapp/api/performance_data.py:66: local variable 'e' is assigned to but never used treeherder/webapp/api/performance_data.py:90: local variable 'e' is assigned to but never used treeherder/webapp/api/refdata.py:12: 'itertools' imported but unused treeherder/webapp/api/refdata.py:13: 'defaultdict' imported but unused treeherder/webapp/api/utils.py:173: local variable 'oauth_token' is assigned to but never used
Attachment #8549287 -
Flags: review?(mdoglio)
Assignee | ||
Updated•9 years ago
|
Status: NEW → ASSIGNED
Updated•9 years ago
|
Attachment #8549287 -
Flags: review?(mdoglio) → review+
Comment 2•9 years ago
|
||
Commits pushed to master at https://github.com/mozilla/treeherder-service https://github.com/mozilla/treeherder-service/commit/b0d1c0c168e911791022480a9e70160cfcc1f9d7 Bug 1059811 - pyflakes: Remove unused imports https://github.com/mozilla/treeherder-service/commit/6bf711fb4a50e1bd88751b8a1d87b2ae6f789c16 Bug 1059811 - pyflakes: Remove unused variables
Assignee | ||
Comment 3•9 years ago
|
||
Some of the remaining warnings are: ./treeherder/etl/tasks/__init__.py:1:1: F403 'from buildapi_tasks import *' used; unable to detect undefined names ./treeherder/etl/tasks/__init__.py:2:1: F403 'from cleanup_tasks import *' used; unable to detect undefined names ./treeherder/etl/tasks/__init__.py:3:1: F403 'from tbpl_tasks import *' used; unable to detect undefined names ./treeherder/etl/tasks/__init__.py:4:1: F403 'from tasks import *' used; unable to detect undefined names ./treeherder/model/derived/__init__.py:1:1: F403 'from base import *' used; unable to detect undefined names ./treeherder/model/derived/__init__.py:2:1: F403 'from refdata import *' used; unable to detect undefined names ./treeherder/model/derived/__init__.py:3:1: F403 'from jobs import *' used; unable to detect undefined names ./treeherder/settings/__init__.py:1:1: F403 'from base import *' used; unable to detect undefined names ./treeherder/settings/base.py:319:5: F403 'from local import *' used; unable to detect undefined names ./treeherder/webapp/admin.py:6:1: F403 'from treeherder.model.models import *' used; unable to detect undefined names Mauro, would you prefer me to switch these to explicit imports, or add warning type F403 to the ignore list?
Flags: needinfo?(mdoglio)
Comment 4•9 years ago
|
||
I would prefer to have it added to the ignore list.
Flags: needinfo?(mdoglio)
Assignee | ||
Comment 5•9 years ago
|
||
(In reply to Mauro Doglio [:mdoglio] from comment #4) > I would prefer to have it added to the ignore list. sgtm - have added to the configs PR in bug 1107523.
Assignee | ||
Comment 6•9 years ago
|
||
This fixes: tests/etl/test_tbpl.py:5:1: F401 'datetime' imported but unused treeherder/__init__.py:4:1: F401 'celery_app' imported but unused treeherder/etl/daemon.py:71:19: F841 local variable 'e' is assigned to but never used treeherder/model/derived/jobs.py:893:9: F841 local variable 'where_in_clause' is assigned to but never used treeherder/model/derived/jobs.py:2177:13: F841 local variable 'job_id' is assigned to but never used treeherder/workers/models.py:5:1: F401 'models' imported but unused However I'm dubious about the unused 'where_in_clause' in jobs.py - it looks perhaps that it was intended to have been passed to jobs_execute()'s 'replace', here: https://github.com/mozilla/treeherder-service/blob/c99cc67a70ed94f6694b9bed968373edb89e4fd2/treeherder/model/derived/jobs.py#L899
Attachment #8551770 -
Flags: review?(mdoglio)
Updated•9 years ago
|
Attachment #8551770 -
Flags: review?(mdoglio) → review+
Assignee | ||
Comment 7•9 years ago
|
||
Did you see this concern? :-) (In reply to Ed Morley [:edmorley] from comment #6) > However I'm dubious about the unused 'where_in_clause' in jobs.py - it looks > perhaps that it was intended to have been passed to jobs_execute()'s > 'replace', here: > https://github.com/mozilla/treeherder-service/blob/ > c99cc67a70ed94f6694b9bed968373edb89e4fd2/treeherder/model/derived/jobs. > py#L899
Flags: needinfo?(mdoglio)
Comment 8•9 years ago
|
||
Yeah, according to the docstrings the where_in_list param passed to that function is a list while the replacements should be strings. I would write a unit test to double check that
Flags: needinfo?(mdoglio)
Comment 9•9 years ago
|
||
Commit pushed to master at https://github.com/mozilla/treeherder-service https://github.com/mozilla/treeherder-service/commit/de6a0557bcc4bf42fb3af3ae0e0288f0aa167d9d Bug 1059811 - Fix remaining pyflakes warnings
Assignee | ||
Comment 10•9 years ago
|
||
(In reply to Mauro Doglio [:mdoglio] from comment #8) > Yeah, according to the docstrings the where_in_list param passed to that > function is a list while the replacements should be strings. I would write a > unit test to double check that Filed bug 1126324 & landed the PR here, so we can close this out for now :-)
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Comment 11•9 years ago
|
||
Commit pushed to master at https://github.com/mozilla/treeherder-service https://github.com/mozilla/treeherder-service/commit/9b97fbd85e3479099c90c935fae55a738ff348ce Bug 1059811 - Fix pyflakes unused variable warnings test_resultset_api.py:294:5: F841 local variable 'email' is assigned to but never used test_resultset_api.py:305:5: F841 local variable 'resp' is assigned to but never used
You need to log in
before you can comment on or make changes to this bug.
Description
•