Skip to content

Commit 1ddc9a9

Browse files
committed
lint: fix flake8 and pylint violations
Basic CI has never run against this repository, so the tree has drifted out of line with .flake8 and .pylintrc. Fix the violations so the lint job can pass: F541 f-string without placeholders (cli.py) E501 line too long (cli.py) W391 blank line at end of file (artifacts.py) F401 unused imports (pull_labs_poller.py, test_pull_labs_translate.py) E306 missing blank line before nested definition (test_kcidb_submit.py) W0714 overlapping excepts, JSONDecodeError derives from ValueError (setup_validate.py) W0613 unused argument (test_kcidb_submit.py) W0212 protected access in tests (test_role_manager.py) These changes are extracted unmodified from PR kernelci#26 by Norbert Manthey, which fixes them alongside its feature work. Signed-off-by: Ben Copeland <ben.copeland@linaro.org>
1 parent 2f5cffe commit 1ddc9a9

7 files changed

Lines changed: 13 additions & 11 deletions

File tree

src/kernel_ci_cloud_labs/cli.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,8 +292,11 @@ def main():
292292
val_parser.add_argument("--bucket", help="S3 bucket to verify (and create with --fix)")
293293
val_parser.add_argument("--role", help="IAM role name used by VM instance profiles")
294294
val_parser.add_argument("--region", default="us-west-2", help="AWS region (default: us-west-2)")
295-
val_parser.add_argument("--api-url", help=f"KernelCI API base URI (overrides $KERNELCI_API_BASE_URI)")
296-
val_parser.add_argument("--fix", action="store_true", help="Create missing resources (S3 bucket) instead of just reporting them")
295+
val_parser.add_argument("--api-url", help="KernelCI API base URI (overrides $KERNELCI_API_BASE_URI)")
296+
val_parser.add_argument(
297+
"--fix", action="store_true",
298+
help="Create missing resources (S3 bucket) instead of just reporting them",
299+
)
297300
val_parser.set_defaults(func=cmd_setup_validate)
298301

299302
args = parser.parse_args()

src/kernel_ci_cloud_labs/core/artifacts.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,5 +262,3 @@ def collect_run_artifacts(
262262
manifest_path,
263263
)
264264
return manifest
265-
266-

src/kernel_ci_cloud_labs/pull_labs_poller.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@
4545

4646
from kernel_ci_cloud_labs.kcidb_submit import (
4747
build_test_row,
48-
submit_tests,
4948
to_kcidb_status,
5049
)
5150
from kernel_ci_cloud_labs.pull_labs_translate import translate_job
@@ -314,7 +313,7 @@ def _validate_default_executor_deps() -> None:
314313

315314
problems: List[str] = []
316315
try:
317-
import boto3 # noqa: F401,PLC0415
316+
import boto3 # noqa: F401,PLC0415 # pylint: disable=unused-import
318317
except ImportError as e:
319318
problems.append(
320319
f"boto3 import failed ({e}) — run: python3.11 -m pip install -e ."

src/kernel_ci_cloud_labs/setup_validate.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ def _check_bucket_policy_statement(s3, bucket_name: str, fix: bool) -> bool:
200200
print(f"✗ Could not read bucket policy ({code}): {e}")
201201
return False
202202
existing = None
203-
except (ValueError, json.JSONDecodeError) as e:
203+
except ValueError as e:
204204
print(f"✗ Bucket policy is not valid JSON: {e}")
205205
return False
206206

@@ -365,7 +365,7 @@ def check_kcidb_jwt() -> bool:
365365
# JWT payload is base64url; pad to a multiple of 4 before decoding.
366366
payload_b64 = parts[1] + "=" * (-len(parts[1]) % 4)
367367
payload = json.loads(base64.urlsafe_b64decode(payload_b64))
368-
except (ValueError, json.JSONDecodeError) as e:
368+
except ValueError as e:
369369
print(f"✗ JWT payload not decodable: {e}")
370370
return False
371371

tests/test_kcidb_submit.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,8 +187,10 @@ def test_submit_revision_posts_with_bearer_auth(self):
187187
class FakeResp:
188188
def __enter__(self):
189189
return self
190+
190191
def __exit__(self, *a):
191192
return False
193+
192194
def read(self):
193195
return b'{"status":"ok","id":"sub-1"}'
194196

@@ -237,7 +239,7 @@ def __enter__(self): return self
237239
def __exit__(self, *a): return False
238240
def read(self): return b'{}'
239241

240-
def fake_urlopen(req, timeout=None):
242+
def fake_urlopen(req, timeout=None): # pylint: disable=unused-argument
241243
captured["body"] = json.loads(req.data.decode("utf-8"))
242244
return FakeResp()
243245

@@ -264,7 +266,7 @@ def __enter__(self): return self
264266
def __exit__(self, *a): return False
265267
def read(self): return b'{}'
266268

267-
def fake_urlopen(req, timeout=None):
269+
def fake_urlopen(req, timeout=None): # pylint: disable=unused-argument
268270
captured["body"] = json.loads(req.data.decode("utf-8"))
269271
return FakeResp()
270272

tests/test_pull_labs_translate.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
from kernel_ci_cloud_labs.pull_labs_translate import (
1111
DEFAULT_PLATFORM_MAP,
12-
DEFAULT_TEST_TYPE_MAP,
1312
translate_job,
1413
)
1514

tests/test_role_manager.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Unit tests for AWS Role Manager"""
2+
# pylint: disable=protected-access
23

34
__authors__ = ["Max Hubmann <mxhbm@amazon.de>", "Norbert Manthey <nmanthey@amazon.de>"]
45
__copyright__ = "Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved."

0 commit comments

Comments
 (0)