Skip to content

Commit 9f2d682

Browse files
committed
👹 Feed the hobgoblins (delint).
1 parent 7d632f2 commit 9f2d682

File tree

6 files changed

+49
-63
lines changed

6 files changed

+49
-63
lines changed

‎importlib_metadata/__init__.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -769,6 +769,7 @@ class Lookup:
769769
"""
770770
A micro-optimized class for searching a (fast) path for metadata.
771771
"""
772+
772773
def __init__(self, path: FastPath):
773774
"""
774775
Calculate all of the children representing metadata.

‎importlib_metadata/_meta.py‎

Lines changed: 21 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -9,30 +9,27 @@
99

1010

1111
class PackageMetadata(Protocol):
12-
def __len__(self) -> int:
13-
... # pragma: no cover
12+
def __len__(self) -> int: ... # pragma: no cover
1413

15-
def __contains__(self, item: str) -> bool:
16-
... # pragma: no cover
14+
def __contains__(self, item: str) -> bool: ... # pragma: no cover
1715

18-
def __getitem__(self, key: str) -> str:
19-
... # pragma: no cover
16+
def __getitem__(self, key: str) -> str: ... # pragma: no cover
2017

21-
def __iter__(self) -> Iterator[str]:
22-
... # pragma: no cover
18+
def __iter__(self) -> Iterator[str]: ... # pragma: no cover
2319

2420
@overload
25-
def get(self, name: str, failobj: None = None) -> Optional[str]:
26-
... # pragma: no cover
21+
def get(
22+
self, name: str, failobj: None = None
23+
) -> Optional[str]: ... # pragma: no cover
2724

2825
@overload
29-
def get(self, name: str, failobj: _T) -> Union[str, _T]:
30-
... # pragma: no cover
26+
def get(self, name: str, failobj: _T) -> Union[str, _T]: ... # pragma: no cover
3127

3228
# overload per python/importlib_metadata#435
3329
@overload
34-
def get_all(self, name: str, failobj: None = None) -> Optional[List[Any]]:
35-
... # pragma: no cover
30+
def get_all(
31+
self, name: str, failobj: None = None
32+
) -> Optional[List[Any]]: ... # pragma: no cover
3633

3734
@overload
3835
def get_all(self, name: str, failobj: _T) -> Union[List[Any], _T]:
@@ -52,21 +49,19 @@ class SimplePath(Protocol):
5249
A minimal subset of pathlib.Path required by Distribution.
5350
"""
5451

55-
def joinpath(self, other: Union[str, os.PathLike[str]]) -> SimplePath:
56-
... # pragma: no cover
52+
def joinpath(
53+
self, other: Union[str, os.PathLike[str]]
54+
) -> SimplePath: ... # pragma: no cover
5755

58-
def __truediv__(self, other: Union[str, os.PathLike[str]]) -> SimplePath:
59-
... # pragma: no cover
56+
def __truediv__(
57+
self, other: Union[str, os.PathLike[str]]
58+
) -> SimplePath: ... # pragma: no cover
6059

6160
@property
62-
def parent(self) -> SimplePath:
63-
... # pragma: no cover
61+
def parent(self) -> SimplePath: ... # pragma: no cover
6462

65-
def read_text(self, encoding=None) -> str:
66-
... # pragma: no cover
63+
def read_text(self, encoding=None) -> str: ... # pragma: no cover
6764

68-
def read_bytes(self) -> bytes:
69-
... # pragma: no cover
65+
def read_bytes(self) -> bytes: ... # pragma: no cover
7066

71-
def exists(self) -> bool:
72-
... # pragma: no cover
67+
def exists(self) -> bool: ... # pragma: no cover

‎importlib_metadata/_py39compat.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""
22
Compatibility layer with Python 3.8/3.9
33
"""
4+
45
from typing import TYPE_CHECKING, Any, Optional
56

67
if TYPE_CHECKING: # pragma: no cover

‎tests/_path.py‎

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,15 @@ class Symlink(str):
1717

1818
@runtime_checkable
1919
class TreeMaker(Protocol):
20-
def __truediv__(self, *args, **kwargs):
21-
... # pragma: no cover
20+
def __truediv__(self, *args, **kwargs): ... # pragma: no cover
2221

23-
def mkdir(self, **kwargs):
24-
... # pragma: no cover
22+
def mkdir(self, **kwargs): ... # pragma: no cover
2523

26-
def write_text(self, content, **kwargs):
27-
... # pragma: no cover
24+
def write_text(self, content, **kwargs): ... # pragma: no cover
2825

29-
def write_bytes(self, content):
30-
... # pragma: no cover
26+
def write_bytes(self, content): ... # pragma: no cover
3127

32-
def symlink_to(self, target):
33-
... # pragma: no cover
28+
def symlink_to(self, target): ... # pragma: no cover
3429

3530

3631
def _ensure_tree_maker(obj: Union[str, TreeMaker]) -> TreeMaker:

‎tests/fixtures.py‎

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -140,15 +140,13 @@ class DistInfoPkgEditable(DistInfoPkg):
140140
some_hash = '524127ce937f7cb65665130c695abd18ca386f60bb29687efb976faa1596fdcc'
141141
files: FilesSpec = {
142142
'distinfo_pkg-1.0.0.dist-info': {
143-
'direct_url.json': json.dumps(
144-
{
145-
"archive_info": {
146-
"hash": f"sha256={some_hash}",
147-
"hashes": {"sha256": f"{some_hash}"},
148-
},
149-
"url": "file:///path/to/distinfo_pkg-1.0.0.editable-py3-none-any.whl",
150-
}
151-
)
143+
'direct_url.json': json.dumps({
144+
"archive_info": {
145+
"hash": f"sha256={some_hash}",
146+
"hashes": {"sha256": f"{some_hash}"},
147+
},
148+
"url": "file:///path/to/distinfo_pkg-1.0.0.editable-py3-none-any.whl",
149+
})
152150
},
153151
}
154152

‎tests/test_main.py‎

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -304,12 +304,10 @@ def test_sortable(self):
304304
"""
305305
EntryPoint objects are sortable, but result is undefined.
306306
"""
307-
sorted(
308-
[
309-
EntryPoint(name='b', value='val', group='group'),
310-
EntryPoint(name='a', value='val', group='group'),
311-
]
312-
)
307+
sorted([
308+
EntryPoint(name='b', value='val', group='group'),
309+
EntryPoint(name='a', value='val', group='group'),
310+
])
313311

314312

315313
class FileSystem(
@@ -376,18 +374,16 @@ def test_packages_distributions_all_module_types(self):
376374
'all_distributions-1.0.0.dist-info': metadata,
377375
}
378376
for i, suffix in enumerate(suffixes):
379-
files.update(
380-
{
381-
f'importable-name {i}{suffix}': '',
382-
f'in_namespace_{i}': {
383-
f'mod{suffix}': '',
384-
},
385-
f'in_package_{i}': {
386-
'__init__.py': '',
387-
f'mod{suffix}': '',
388-
},
389-
}
390-
)
377+
files.update({
378+
f'importable-name {i}{suffix}': '',
379+
f'in_namespace_{i}': {
380+
f'mod{suffix}': '',
381+
},
382+
f'in_package_{i}': {
383+
'__init__.py': '',
384+
f'mod{suffix}': '',
385+
},
386+
})
391387
metadata.update(RECORD=fixtures.build_record(files))
392388
fixtures.build_files(files, prefix=self.site_dir)
393389

0 commit comments

Comments
 (0)