Skip to content

Commit 4dbf23e

Browse files
committed
pre-commit autoupdate
1 parent 5329c91 commit 4dbf23e

File tree

3 files changed

+17
-16
lines changed

3 files changed

+17
-16
lines changed

.pre-commit-config.yaml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,16 @@ repos:
1414
rev: v3.12.0
1515
hooks:
1616
- id: reorder-python-imports
17-
args: ['--py38-plus']
17+
args: ['--py39-plus']
1818
- repo: https://github.com/asottile/add-trailing-comma
1919
rev: v3.1.0
2020
hooks:
2121
- id: add-trailing-comma
22-
args: ['--py36-plus']
2322
- repo: https://github.com/asottile/pyupgrade
2423
rev: v3.15.2
2524
hooks:
2625
- id: pyupgrade
27-
args: ['--py38-plus']
26+
args: ['--py310-plus']
2827
- repo: https://github.com/hhatto/autopep8
2928
rev: v2.1.0
3029
hooks:

pypi_browser/packaging.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,17 @@
1313

1414

1515
# Copied from distlib/wheel.py
16-
WHEEL_FILENAME_RE = re.compile(r'''
16+
WHEEL_FILENAME_RE = re.compile(
17+
r'''
1718
(?P<nm>[^-]+)
1819
-(?P<vn>\d+[^-]*)
1920
(-(?P<bn>\d+[^-]*))?
2021
-(?P<py>\w+\d+(\.\w+\d+)*)
2122
-(?P<bi>\w+)
2223
-(?P<ar>\w+(\.\w+)*)
2324
\.whl$
24-
''', re.IGNORECASE | re.VERBOSE)
25+
''', re.IGNORECASE | re.VERBOSE,
26+
)
2527

2628

2729
def pep426_normalize(package_name: str) -> str:
@@ -92,7 +94,7 @@ class PackageEntry:
9294
size: int
9395

9496

95-
def _package_entries_from_zipfile(path: str) -> typing.Set[PackageEntry]:
97+
def _package_entries_from_zipfile(path: str) -> set[PackageEntry]:
9698
with zipfile.ZipFile(path) as zf:
9799
return {
98100
PackageEntry(
@@ -105,7 +107,7 @@ def _package_entries_from_zipfile(path: str) -> typing.Set[PackageEntry]:
105107
}
106108

107109

108-
def _package_entries_from_tarball(path: str) -> typing.Set[PackageEntry]:
110+
def _package_entries_from_tarball(path: str) -> set[PackageEntry]:
109111
with tarfile.open(path) as tf:
110112
return {
111113
PackageEntry(
@@ -130,9 +132,9 @@ async def __aenter__(self) -> 'AsyncArchiveFile':
130132

131133
async def __aexit__(
132134
self,
133-
exc_t: typing.Optional[typing.Type[BaseException]],
134-
exc_v: typing.Optional[BaseException],
135-
exc_tb: typing.Optional[TracebackType],
135+
exc_t: type[BaseException] | None,
136+
exc_v: BaseException | None,
137+
exc_tb: TracebackType | None,
136138
) -> None:
137139
await asyncio.to_thread(self.file_.close)
138140

@@ -171,7 +173,7 @@ def from_path(cls, path: str) -> 'Package':
171173
path=path,
172174
)
173175

174-
async def entries(self) -> typing.Set[PackageEntry]:
176+
async def entries(self) -> set[PackageEntry]:
175177
if self.package_format is PackageFormat.ZIPFILE:
176178
return await asyncio.to_thread(_package_entries_from_zipfile, self.path)
177179
elif self.package_format is PackageFormat.TARBALL:

pypi_browser/pypi.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
class PythonRepository(abc.ABC):
1919

2020
@abc.abstractmethod
21-
async def files_for_package(self, package_name: str) -> typing.Dict[str, str]:
21+
async def files_for_package(self, package_name: str) -> dict[str, str]:
2222
"""Return mapping from filename to file URL for files in a package."""
2323

2424

@@ -41,7 +41,7 @@ class SimpleRepository(PythonRepository):
4141
# TODO: Also handle PEP691 JSON simple repositories.
4242
pypi_url: str
4343

44-
async def files_for_package(self, package_name: str) -> typing.Dict[str, str]:
44+
async def files_for_package(self, package_name: str) -> dict[str, str]:
4545
async with httpx.AsyncClient() as client:
4646
resp = await client.get(
4747
f'{self.pypi_url}/{package_name}',
@@ -67,7 +67,7 @@ class LegacyJsonRepository(PythonRepository):
6767
"""Non-standardized JSON API compatible with pypi.org's /pypi/*/json endpoints."""
6868
pypi_url: str
6969

70-
async def files_for_package(self, package_name: str) -> typing.Dict[str, str]:
70+
async def files_for_package(self, package_name: str) -> dict[str, str]:
7171
async with httpx.AsyncClient() as client:
7272
resp = await client.get(
7373
f'{self.pypi_url}/pypi/{package_name}/json',
@@ -92,9 +92,9 @@ class PackageDoesNotExist(Exception):
9292
pass
9393

9494

95-
async def files_by_version(config: PyPIConfig, package: str) -> typing.Dict[str | None, typing.Set[str]]:
95+
async def files_by_version(config: PyPIConfig, package: str) -> dict[str | None, set[str]]:
9696
ret = collections.defaultdict(set)
97-
for filename in await config.repo.files_for_package(package):
97+
for filename in await config.repo.files_for_package(package):
9898
try:
9999
version = packaging.guess_version_from_filename(filename)
100100
except ValueError:

0 commit comments

Comments
 (0)