Scripts: Type annotations, linting

This commit is contained in:
wurstsalat
2022-11-29 19:36:31 +01:00
parent 067c233b4b
commit 32c8534b1f
2 changed files with 4 additions and 8 deletions

View File

@@ -2,10 +2,7 @@
# Keep this file python 3.7 compatible because it is executed on the server # Keep this file python 3.7 compatible because it is executed on the server
from typing import Any from typing import Any
from typing import Dict
from typing import Iterator from typing import Iterator
from typing import Set
from typing import Dict
import sys import sys
import json import json
@@ -20,7 +17,7 @@ logging.basicConfig(format=FORMAT, level=logging.DEBUG)
log = logging.getLogger() log = logging.getLogger()
REQUIRED_KEYS: Set[str] = { REQUIRED_KEYS: set[str] = {
'authors', 'authors',
'description', 'description',
'homepage', 'homepage',
@@ -32,7 +29,7 @@ REQUIRED_KEYS: Set[str] = {
'version' 'version'
} }
PACKAGE_INDEX: Dict[str, Any] = { PACKAGE_INDEX: dict[str, Any] = {
'metadata': { 'metadata': {
'repository_name': 'master', 'repository_name': 'master',
'image_path': 'images.zip', 'image_path': 'images.zip',
@@ -41,12 +38,12 @@ PACKAGE_INDEX: Dict[str, Any] = {
} }
def is_manifest_valid(manifest: Dict[str, Any]) -> bool: def is_manifest_valid(manifest: dict[str, Any]) -> bool:
manifest_keys = set(manifest.keys()) manifest_keys = set(manifest.keys())
return REQUIRED_KEYS.issubset(manifest_keys) return REQUIRED_KEYS.issubset(manifest_keys)
def iter_releases(release_folder: Path) -> Iterator[Dict[str, Any]]: def iter_releases(release_folder: Path) -> Iterator[dict[str, Any]]:
for path in release_folder.rglob('*.zip'): for path in release_folder.rglob('*.zip'):
with ZipFile(path) as release_zip: with ZipFile(path) as release_zip:
if path.name == 'images.zip': if path.name == 'images.zip':

View File

@@ -4,7 +4,6 @@ import argparse
import re import re
import subprocess import subprocess
from pathlib import Path from pathlib import Path
import sys
REPO_DIR = Path(__file__).parent.parent REPO_DIR = Path(__file__).parent.parent