Skip to content

Commit d7ca08a

Browse files
committed
repogen: clean up some Python type hint stuff
1 parent 8cc58ed commit d7ca08a

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

repogen/ipk_file.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import io
22
import json
33
import tarfile
4-
from typing import TypedDict, NotRequired, Optional
4+
from typing import TypedDict, NotRequired
55

66
import ar
77
from debian_parser import PackagesParser
88

99

1010
class Control(TypedDict):
1111
version: str
12-
installedSize: Optional[int]
12+
installedSize: int | None
1313

1414

1515
class AppInfo(TypedDict):
@@ -20,7 +20,7 @@ class AppInfo(TypedDict):
2020
appDescription: NotRequired[str]
2121

2222

23-
def get_appinfo(ipk_path: str) -> (Control, AppInfo):
23+
def get_appinfo(ipk_path: str) -> tuple[Control, AppInfo]:
2424
with open(ipk_path, 'rb') as f:
2525
archive = ar.Archive(f)
2626
control_file = io.BytesIO(archive.open('control.tar.gz', mode='rb').read())

repogen/pkg_info.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import sys
33
from datetime import datetime
44
from pathlib import Path
5-
from typing import TypedDict, Optional, List, NotRequired
5+
from typing import TypedDict, List, NotRequired
66

77
import nh3
88

@@ -46,7 +46,7 @@ def load_registry(info_path: Path) -> tuple[str, PackageRegistry]:
4646
return pkgid, content
4747

4848

49-
def from_package_info_file(info_path: Path, offline=False) -> Optional[PackageInfo]:
49+
def from_package_info_file(info_path: Path, offline=False) -> PackageInfo | None:
5050
pkgid, content = load_registry(info_path)
5151
return from_package_info(pkgid, content, offline)
5252

@@ -104,10 +104,10 @@ def from_package_info(pkgid: str, content: PackageRegistry, offline=False) -> Pa
104104
return pkginfo
105105

106106

107-
def list_packages(pkgdir: Path, packages: Optional[List[str]] = None, offline: bool = False) -> List[PackageInfo]:
107+
def list_packages(pkgdir: Path, packages: List[str] | None = None, offline: bool = False) -> List[PackageInfo]:
108108
paths: List[Path] = [f for f in pkgdir.iterdir() if f.is_file()]
109109

110-
def map_package_info(p: Path) -> Optional[PackageInfo]:
110+
def map_package_info(p: Path) -> PackageInfo | None:
111111
pkgid, content = load_registry(p)
112112
if packages and pkgid not in packages:
113113
return None

repogen/pkg_manifest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import urllib.parse
44
from datetime import datetime
55
from email.utils import parsedate_to_datetime
6-
from typing import TypedDict, Optional, NotRequired, Literal
6+
from typing import TypedDict, NotRequired, Literal
77
from urllib.parse import urljoin
88
from urllib.request import url2pathname
99

@@ -22,7 +22,7 @@ class PackageManifest(TypedDict):
2222
title: str
2323
version: str
2424
type: str
25-
appDescription: Optional[str]
25+
appDescription: str | None
2626
iconUri: str
2727
sourceUrl: NotRequired[str]
2828
rootRequired: NotRequired[bool | Literal['optional']]

repogen/pkg_registery.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@ class PackageRegistry(TypedDict):
2222
funding: NotRequired[dict[str, List[str]]]
2323

2424

25-
def parse_yml_package(p: Path) -> (str, PackageRegistry):
25+
def parse_yml_package(p: Path) -> tuple[str, PackageRegistry]:
2626
with p.open(encoding='utf-8') as f:
2727
content: PackageRegistry = yaml.safe_load(f)
2828
return p.stem, content
2929

3030

3131
# noinspection PyUnresolvedReferences
32-
def load_py_package(p: Path) -> (str, PackageRegistry):
32+
def load_py_package(p: Path) -> tuple[str, PackageRegistry]:
3333
pkgid = p.stem
3434
spec = importlib.util.spec_from_file_location(f"pkg.{pkgid}", p)
3535
module = importlib.util.module_from_spec(spec)

0 commit comments

Comments
 (0)