Skip to content

[th/flake8] enable flake8 linter in github actions and fix existing warnings #39

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

Merged
merged 11 commits into from
May 28, 2024

Conversation

thom311
Copy link
Collaborator

@thom311 thom311 commented May 27, 2024

enable flake8 linter in github actions and fix existing warnings

thom311 added 11 commits May 27, 2024 21:13
  $ flake8 --select F541
  ./evaluator.py:195:29: F541 f-string is missing placeholders
  ./evaluator.py:243:17: F541 f-string is missing placeholders
  ./netperf.py:76:25: F541 f-string is missing placeholders
  ./task.py:59:25: F541 f-string is missing placeholders
  ./task.py:75:25: F541 f-string is missing placeholders
  ./trafficFlowTests.py:84:29: F541 f-string is missing placeholders
  ./trafficFlowTests.py:90:29: F541 f-string is missing placeholders
  ./validateOffload.py:51:25: F541 f-string is missing placeholders
  ./validateOffload.py:55:25: F541 f-string is missing placeholders
  ./validateOffload.py:141:29: F541 f-string is missing placeholders
  ./validateOffload.py:143:29: F541 f-string is missing placeholders
  $ flake8 --select F401
  ./arguments.py:1:1: F401 'os' imported but unused
  ./common.py:4:1: F401 'typing.Generic' imported but unused
  ./evaluator.py:6:1: F401 'common.TftAggregateOutput' imported but unused
  ./iperf.py:2:1: F401 'common.PodType' imported but unused
  ./iperf.py:6:1: F401 'task.Task' imported but unused
  ./iperf.py:10:1: F401 'time' imported but unused
  ./iperf.py:12:1: F401 'sys' imported but unused
  ./main.py:4:1: F401 'sys' imported but unused
  ./main.py:5:1: F401 'pathlib.Path' imported but unused
  ./netperf.py:2:1: F401 'common.PodType' imported but unused
  ./netperf.py:6:1: F401 'task.Task' imported but unused
  ./netperf.py:9:1: F401 'json' imported but unused
  ./netperf.py:10:1: F401 'time' imported but unused
  ./netperf.py:12:1: F401 'sys' imported but unused
  ./perf.py:2:1: F401 'common.TestType' imported but unused
  ./perf.py:2:1: F401 'common.IperfOutput' imported but unused
  ./perf.py:5:1: F401 'thread.ReturnValueThread' imported but unused
  ./perf.py:7:1: F401 'common.Result' imported but unused
  ./perf.py:9:1: F401 'json' imported but unused
  ./task.py:5:1: F401 'typing.Optional' imported but unused
  ./task.py:11:1: F401 'typing.Union' imported but unused
  ./task.py:11:1: F401 'typing.List' imported but unused
  ./tests/test_evaluator.py:1:1: F401 'sys' imported but unused
  ./trafficFlowTests.py:1:1: F401 'common.BaseOutput' imported but unused
  ./trafficFlowTests.py:15:1: F401 'iperf' imported but unused
  ./trafficFlowTests.py:31:1: F401 'typing.Optional' imported but unused
  ./validateOffload.py:10:1: F401 'dataclasses.asdict' imported but unused
  ./validateOffload.py:10:1: F401 'dataclasses.is_dataclass' imported but unused
  ./validateOffload.py:12:1: F401 'time' imported but unused
  ./validateOffload.py:14:1: F401 'iperf.IperfServer' imported but unused
  ./validateOffload.py:14:1: F401 'iperf.IperfClient' imported but unused
  ./validateOffload.py:18:1: F401 'typing.Optional' imported but unused
  ./validateOffload.py:18:1: F401 'typing.Tuple' imported but unused
  ./validateOffload.py:19:1: F401 'sys' imported but unused
  $ flake8 --select F811
  ./common.py:4:1: F811 redefinition of unused 'List' from line 4
  $ flake8 --select F841
  ./tests/test_common.py:77:5: F841 local variable output_dict is assigned to but never used
  ./tests/test_evaluator.py:29:5: F841 local variable result is assigned to but never used
  $ flake8 --select F405
  ./tests/test_common.py:12:12: F405 'enum_convert' may be undefined, or defined from star imports: common
  ./tests/test_common.py:12:25: F405 'TestType' may be undefined, or defined from star imports: common
  ./tests/test_common.py:12:51: F405 'TestType' may be undefined, or defined from star imports: common
  ./tests/test_common.py:13:12: F405 'enum_convert' may be undefined, or defined from star imports: common
  ./tests/test_common.py:13:25: F405 'PodType' may be undefined, or defined from star imports: common
  ./tests/test_common.py:13:40: F405 'PodType' may be undefined, or defined from star imports: common
  ./tests/test_common.py:15:9: F405 'enum_convert' may be undefined, or defined from star imports: common
  ./tests/test_common.py:15:22: F405 'TestType' may be undefined, or defined from star imports: common
  ./tests/test_common.py:17:9: F405 'enum_convert' may be undefined, or defined from star imports: common
  ./tests/test_common.py:17:22: F405 'TestType' may be undefined, or defined from star imports: common
  ./tests/test_common.py:21:11: F405 'PodInfo' may be undefined, or defined from star imports: common
  ./tests/test_common.py:21:45: F405 'PodType' may be undefined, or defined from star imports: common
  ./tests/test_common.py:23:28: F405 'PodType' may be undefined, or defined from star imports: common
  ./tests/test_common.py:29:14: F405 'PodInfo' may be undefined, or defined from star imports: common
  ./tests/test_common.py:30:37: F405 'PodType' may be undefined, or defined from star imports: common
  ./tests/test_common.py:32:14: F405 'PodInfo' may be undefined, or defined from star imports: common
  ./tests/test_common.py:33:37: F405 'PodType' may be undefined, or defined from star imports: common
  ./tests/test_common.py:35:16: F405 'TestMetadata' may be undefined, or defined from star imports: common
  ./tests/test_common.py:37:22: F405 'TestCaseType' may be undefined, or defined from star imports: common
  ./tests/test_common.py:38:19: F405 'TestType' may be undefined, or defined from star imports: common
  ./tests/test_common.py:43:37: F405 'TestCaseType' may be undefined, or defined from star imports: common
  ./tests/test_common.py:44:34: F405 'TestType' may be undefined, or defined from star imports: common
  ./tests/test_common.py:49:21: F405 'TestMetadata' may be undefined, or defined from star imports: common
  ./tests/test_common.py:57:42: F405 'TestCaseType' may be undefined, or defined from star imports: common
  ./tests/test_common.py:58:39: F405 'TestType' may be undefined, or defined from star imports: common
  ./tests/test_common.py:59:45: F405 'PodInfo' may be undefined, or defined from star imports: common
  ./tests/test_common.py:60:45: F405 'PodInfo' may be undefined, or defined from star imports: common
  ./tests/test_common.py:64:14: F405 'PodInfo' may be undefined, or defined from star imports: common
  ./tests/test_common.py:65:37: F405 'PodType' may be undefined, or defined from star imports: common
  ./tests/test_common.py:67:14: F405 'PodInfo' may be undefined, or defined from star imports: common
  ./tests/test_common.py:68:37: F405 'PodType' may be undefined, or defined from star imports: common
  ./tests/test_common.py:70:16: F405 'TestMetadata' may be undefined, or defined from star imports: common
  ./tests/test_common.py:72:22: F405 'TestCaseType' may be undefined, or defined from star imports: common
  ./tests/test_common.py:73:19: F405 'TestType' may be undefined, or defined from star imports: common
  ./tests/test_common.py:77:5: F405 'IperfOutput' may be undefined, or defined from star imports: common
  ./tests/test_common.py:80:9: F405 'IperfOutput' may be undefined, or defined from star imports: common
  ./tests/test_common.py:85:12: F405 'serialize_enum' may be undefined, or defined from star imports: common
  ./tests/test_common.py:85:27: F405 'TestType' may be undefined, or defined from star imports: common
  ./tests/test_common.py:89:22: F405 'TestType' may be undefined, or defined from star imports: common
  ./tests/test_common.py:90:21: F405 'PodType' may be undefined, or defined from star imports: common
  ./tests/test_common.py:93:23: F405 'serialize_enum' may be undefined, or defined from star imports: common
  ./tests/test_common.py:101:18: F405 'TestType' may be undefined, or defined from star imports: common
  ./tests/test_common.py:101:33: F405 'PodType' may be undefined, or defined from star imports: common
  ./tests/test_common.py:102:23: F405 'serialize_enum' may be undefined, or defined from star imports: common
  ./tests/test_common.py:107:41: F405 'TestCaseType' may be undefined, or defined from star imports: common
  ./tests/test_common.py:108:25: F405 'ConnectionMode' may be undefined, or defined from star imports: common
  ./tests/test_common.py:108:53: F405 'NodeLocation' may be undefined, or defined from star imports: common
  ./tests/test_common.py:110:30: F405 'serialize_enum' may be undefined, or defined from star imports: common
  ./tests/test_common.py:117:12: F405 'serialize_enum' may be undefined, or defined from star imports: common
  ./tests/test_common.py:118:12: F405 'serialize_enum' may be undefined, or defined from star imports: common
  $ flake8 --select C408
  ./tests/test_common.py:87:43: C408 Unnecessary dict call - rewrite as a literal.
  ./tests/test_common.py:90:47: C408 Unnecessary dict call - rewrite as a literal.
  $ flake8 --select F402
  ./common.py:207:9: F402 import 'field' from line 2 shadowed by loop variable
  $ flake8 --select E402
  ./tests/test_common.py:7:1: E402 module level import not at top of file
  ./tests/test_common.py:9:1: E402 module level import not at top of file
  ./tests/test_common.py:10:1: E402 module level import not at top of file
  ./tests/test_common.py:11:1: E402 module level import not at top of file
  ./tests/test_common.py:12:1: E402 module level import not at top of file
  ./tests/test_common.py:13:1: E402 module level import not at top of file
  ./tests/test_common.py:14:1: E402 module level import not at top of file
  ./tests/test_common.py:15:1: E402 module level import not at top of file
  ./tests/test_common.py:16:1: E402 module level import not at top of file
  ./tests/test_common.py:17:1: E402 module level import not at top of file
  ./tests/test_common.py:18:1: E402 module level import not at top of file
By restricting the workflow to `main` branch, the actions don't run when
pushing to a branch (unless the branch is named `main`). That means, you
cannot test github actions before opening the pull requests (against
`main`).

That seems undesirable. Enable the workflow for all branches.
@wizhaoredhat
Copy link
Collaborator

@thom311 It is failing to authenticate for some reason.

@thom311
Copy link
Collaborator Author

thom311 commented May 28, 2024

It is failing to authenticate for some reason.

that doesn't seem related to this MR. What is this "build-and-push" job doing?

Could it be, that a merge request by somebody else does not have access to the secrets?

@wizhaoredhat
Copy link
Collaborator

It is supposed to build the container and push it to quay. I added you as a collaborator.

@SalDaniele
Copy link
Collaborator

Yes this job will fail if anyone submits a PR without valid credentials to push to quay.io/wizhao/tft-tools added to their Github secrets

@SalDaniele
Copy link
Collaborator

LGTM, thanks for cleaning this up

@SalDaniele SalDaniele merged commit e417f6c into ovn-kubernetes:main May 28, 2024
1 of 2 checks passed
@thom311 thom311 deleted the th/flake8 branch May 28, 2024 14:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants