Skip to content

Commit 3ce86ec

Browse files
authored
linter fixes (#233)
* not using _bucket property anymore * release notes mock fixed to support quoted version numbers * calling CName constructor with the commit parameter * black-reformatted * disabled useless pyright check for deployment_platform classes * warn() method is deprecated in logging library * replaced unneeded short commit * removed unused imports * removed more unused imports * nuked more unused imports * using cname.cname in download_metadata * reverted release notes test data update to push it in a separate PR * disabled meaningless pyright checks * one more pyright ignore
1 parent 8be8d85 commit 3ce86ec

33 files changed

+302
-152
lines changed

src/gardenlinux/features/cname.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
from ..constants import (
1414
ARCHS,
1515
GL_BUG_REPORT_URL,
16-
GL_COMMIT_SPECIAL_VALUES,
1716
GL_DISTRIBUTION_NAME,
1817
GL_HOME_URL,
1918
GL_RELEASE_ID,

src/gardenlinux/features/metadata_main.py

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,8 @@
66
"""
77

88
import argparse
9-
import logging
10-
import re
11-
from functools import reduce
12-
from os.path import basename, dirname
13-
14-
from .__main__ import (
15-
get_cname_base,
16-
get_minimal_feature_set,
17-
get_version_and_commit_id_from_files,
18-
sort_subset,
19-
)
9+
2010
from .cname import CName
21-
from .parser import Parser
2211

2312
_ARGS_ACTION_ALLOWED = [
2413
"output-release-metadata",

src/gardenlinux/flavors/__main__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
"""
77

88
import json
9-
import os
10-
import sys
119
from argparse import ArgumentParser
1210
from pathlib import Path
1311
from tempfile import TemporaryDirectory

src/gardenlinux/github/__main__.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@
33
from gardenlinux.constants import GARDENLINUX_GITHUB_RELEASE_BUCKET_NAME
44
from gardenlinux.logger import LoggerSetup
55

6-
from .release import create_github_release, upload_to_github_release_page, write_to_release_id_file
6+
from .release import (
7+
create_github_release,
8+
upload_to_github_release_page,
9+
write_to_release_id_file,
10+
)
711
from .release_notes import create_github_release_notes
812

913
LOGGER = LoggerSetup.get_logger("gardenlinux.github", "INFO")
@@ -18,7 +22,7 @@ def main():
1822
create_parser.add_argument("--repo", default="gardenlinux")
1923
create_parser.add_argument("--tag", required=True)
2024
create_parser.add_argument("--commit", required=True)
21-
create_parser.add_argument('--latest', action='store_true', default=False)
25+
create_parser.add_argument("--latest", action="store_true", default=False)
2226
create_parser.add_argument("--dry-run", action="store_true", default=False)
2327

2428
upload_parser = subparsers.add_parser("upload")
@@ -31,7 +35,9 @@ def main():
3135
args = parser.parse_args()
3236

3337
if args.command == "create":
34-
body = create_github_release_notes(args.tag, args.commit, GARDENLINUX_GITHUB_RELEASE_BUCKET_NAME)
38+
body = create_github_release_notes(
39+
args.tag, args.commit, GARDENLINUX_GITHUB_RELEASE_BUCKET_NAME
40+
)
3541
if args.dry_run:
3642
print("Dry Run ...")
3743
print("This release would be created:")

src/gardenlinux/github/release/__init__.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@ def create_github_release(owner, repo, tag, commitish, latest, body):
2727
"body": body,
2828
"draft": False,
2929
"prerelease": False,
30-
"make_latest": "true" if latest else "false"
30+
"make_latest": "true" if latest else "false",
3131
}
3232

3333
response = requests.post(
3434
f"https://api.github.com/repos/{owner}/{repo}/releases",
3535
headers=headers,
3636
data=json.dumps(data),
37-
timeout=REQUESTS_TIMEOUTS
37+
timeout=REQUESTS_TIMEOUTS,
3838
)
3939

4040
if response.status_code == 201:
@@ -84,7 +84,9 @@ def upload_to_github_release_page(
8484
LOGGER.error(f"Error reading file {file_to_upload}: {e}")
8585
return
8686

87-
response = requests.post(upload_url, headers=headers, data=file_contents, timeout=REQUESTS_TIMEOUTS)
87+
response = requests.post(
88+
upload_url, headers=headers, data=file_contents, timeout=REQUESTS_TIMEOUTS
89+
)
8890
if response.status_code == 201:
8991
LOGGER.info("Upload successful")
9092
else:

src/gardenlinux/github/release_notes/__init__.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
)
88

99

10-
def create_github_release_notes(gardenlinux_version, commitish, releases_s3_bucket_name):
10+
def create_github_release_notes(
11+
gardenlinux_version, commitish, releases_s3_bucket_name
12+
):
1113
package_list = get_package_list(gardenlinux_version)
1214

1315
output = ""
@@ -20,7 +22,9 @@ def create_github_release_notes(gardenlinux_version, commitish, releases_s3_buck
2022
gardenlinux_version, package_list
2123
)
2224

23-
metadata_files = download_all_metadata_files(gardenlinux_version, commitish, releases_s3_bucket_name)
25+
metadata_files = download_all_metadata_files(
26+
gardenlinux_version, commitish, releases_s3_bucket_name
27+
)
2428

2529
output += release_notes_image_ids_section(metadata_files)
2630

src/gardenlinux/github/release_notes/deployment_platform/__init__.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from gardenlinux.constants import GARDENLINUX_GITHUB_RELEASE_BUCKET_NAME
22

33

4-
class DeploymentPlatform():
4+
class DeploymentPlatform:
55
artifacts_bucket_name = GARDENLINUX_GITHUB_RELEASE_BUCKET_NAME
66

77
def short_name(self):
@@ -25,7 +25,9 @@ def image_extension(self):
2525
return "raw"
2626

2727
def artifact_for_flavor(self, flavor, markdown_format=True):
28-
base_url = f"https://{self.__class__.artifacts_bucket_name}.s3.amazonaws.com/objects"
28+
base_url = (
29+
f"https://{self.__class__.artifacts_bucket_name}.s3.amazonaws.com/objects"
30+
)
2931
filename = f"{flavor}.{self.image_extension()}"
3032
download_url = f"{base_url}/{flavor}/{filename}"
3133
if markdown_format:
@@ -48,7 +50,9 @@ def region_details(self, image_metadata):
4850
"image_id": image_id,
4951
"image_name": image_name,
5052
}:
51-
details += f"**{region_name}:** {image_id} ({image_name})<br>"
53+
details += (
54+
f"**{region_name}:** {image_id} ({image_name})<br>"
55+
)
5256
case {"region": region_name, "image_id": image_id}:
5357
details += f"**{region_name}:** {image_id}<br>"
5458
case {"details": details_dict}:
@@ -93,7 +97,9 @@ def summary_text(self, image_metadata):
9397
}:
9498
gallery_count = len(gallery_images)
9599
marketplace_count = len(marketplace_images)
96-
return f"{gallery_count} gallery + {marketplace_count} marketplace images"
100+
return (
101+
f"{gallery_count} gallery + {marketplace_count} marketplace images"
102+
)
97103
case {"gallery_images": gallery_images}:
98104
gallery_count = len(gallery_images)
99105
return f"{gallery_count} gallery images"

src/gardenlinux/github/release_notes/deployment_platform/ali_cloud.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# pyright: reportIncompatibleMethodOverride=false
12
from . import DeploymentPlatform
23

34

src/gardenlinux/github/release_notes/deployment_platform/amazon_web_services.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# pyright: reportIncompatibleMethodOverride=false
12
from . import DeploymentPlatform
23

34

src/gardenlinux/github/release_notes/deployment_platform/azure.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# pyright: reportIncompatibleMethodOverride=false
12
from . import DeploymentPlatform
23

34

0 commit comments

Comments
 (0)