Skip to content

Commit b1d2187

Browse files
committed
👹 Feed the hobgoblins (delint).
1 parent 7c16505 commit b1d2187

File tree

6 files changed

+22
-22
lines changed

6 files changed

+22
-22
lines changed

‎importlib_resources/_common.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88
import tempfile
99
import types
1010
import warnings
11-
from typing import Optional, Union, cast
11+
from typing import Optional, cast
1212

1313
from .abc import ResourceReader, Traversable
1414

15-
Package = Union[types.ModuleType, str]
15+
Package = types.ModuleType | str
1616
Anchor = Package
1717

1818

‎importlib_resources/abc.py‎

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,21 @@
22
import itertools
33
import os
44
import pathlib
5+
from collections.abc import Iterable, Iterator
56
from typing import (
67
Any,
78
BinaryIO,
8-
Iterable,
9-
Iterator,
10-
NoReturn,
119
Literal,
10+
NoReturn,
1211
Optional,
1312
Protocol,
1413
Text,
1514
TextIO,
16-
Union,
1715
overload,
1816
runtime_checkable,
1917
)
2018

21-
StrPath = Union[str, os.PathLike[str]]
19+
StrPath = str | os.PathLike[str]
2220

2321
__all__ = ["ResourceReader", "Traversable", "TraversableResources"]
2422

@@ -151,9 +149,7 @@ def open(self, mode: Literal['r'] = 'r', *args: Any, **kwargs: Any) -> TextIO: .
151149
def open(self, mode: Literal['rb'], *args: Any, **kwargs: Any) -> BinaryIO: ...
152150

153151
@abc.abstractmethod
154-
def open(
155-
self, mode: str = 'r', *args: Any, **kwargs: Any
156-
) -> Union[TextIO, BinaryIO]:
152+
def open(self, mode: str = 'r', *args: Any, **kwargs: Any) -> TextIO | BinaryIO:
157153
"""
158154
mode may be 'r' or 'rb' to open as text or binary. Return a handle
159155
suitable for reading (same as pathlib.Path.open).

‎importlib_resources/simple.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import abc
66
import io
77
import itertools
8-
from typing import BinaryIO, List
8+
from typing import BinaryIO
99

1010
from .abc import Traversable, TraversableResources
1111

@@ -24,14 +24,14 @@ def package(self) -> str:
2424
"""
2525

2626
@abc.abstractmethod
27-
def children(self) -> List['SimpleReader']:
27+
def children(self) -> list['SimpleReader']:
2828
"""
2929
Obtain an iterable of SimpleReader for available
3030
child containers (e.g. directories).
3131
"""
3232

3333
@abc.abstractmethod
34-
def resources(self) -> List[str]:
34+
def resources(self) -> list[str]:
3535
"""
3636
Obtain available named resources for this virtual package.
3737
"""

‎importlib_resources/tests/_path.py‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import functools
22
import pathlib
3-
from typing import Dict, Protocol, Union, runtime_checkable
3+
from typing import Protocol, Union, runtime_checkable
44

55
####
66
# from jaraco.path 3.7.1
@@ -12,7 +12,7 @@ class Symlink(str):
1212
"""
1313

1414

15-
FilesSpec = Dict[str, Union[str, bytes, Symlink, 'FilesSpec']]
15+
FilesSpec = dict[str, Union[str, bytes, Symlink, 'FilesSpec']]
1616

1717

1818
@runtime_checkable
@@ -28,13 +28,13 @@ def write_bytes(self, content): ... # pragma: no cover
2828
def symlink_to(self, target): ... # pragma: no cover
2929

3030

31-
def _ensure_tree_maker(obj: Union[str, TreeMaker]) -> TreeMaker:
31+
def _ensure_tree_maker(obj: str | TreeMaker) -> TreeMaker:
3232
return obj if isinstance(obj, TreeMaker) else pathlib.Path(obj) # type: ignore[return-value]
3333

3434

3535
def build(
3636
spec: FilesSpec,
37-
prefix: Union[str, TreeMaker] = pathlib.Path(), # type: ignore[assignment]
37+
prefix: str | TreeMaker = pathlib.Path(), # type: ignore[assignment]
3838
):
3939
"""
4040
Build a set of files/directories, as described by the spec.
@@ -66,7 +66,7 @@ def build(
6666

6767

6868
@functools.singledispatch
69-
def create(content: Union[str, bytes, FilesSpec], path):
69+
def create(content: str | bytes | FilesSpec, path):
7070
path.mkdir(exist_ok=True)
7171
build(content, prefix=path) # type: ignore[arg-type]
7272

‎importlib_resources/tests/test_read.py‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,17 @@ def test_read_bytes(self):
2323

2424
def test_read_text_default_encoding(self):
2525
result = (
26-
resources.files(self.data)
26+
resources
27+
.files(self.data)
2728
.joinpath('utf-8.file')
2829
.read_text(encoding='utf-8')
2930
)
3031
self.assertEqual(result, 'Hello, UTF-8 world!\n')
3132

3233
def test_read_text_given_encoding(self):
3334
result = (
34-
resources.files(self.data)
35+
resources
36+
.files(self.data)
3537
.joinpath('utf-16.file')
3638
.read_text(encoding='utf-16')
3739
)
@@ -83,7 +85,8 @@ def test_read_submodule_resource(self):
8385

8486
def test_read_submodule_resource_by_name(self):
8587
result = (
86-
resources.files('namespacedata01.subdirectory')
88+
resources
89+
.files('namespacedata01.subdirectory')
8790
.joinpath('binary.file')
8891
.read_bytes()
8992
)

‎importlib_resources/tests/test_resource.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,8 @@ def test_read_text_does_not_keep_open(self):
171171
class ResourceFromNamespaceTests:
172172
def test_is_submodule_resource(self):
173173
self.assertTrue(
174-
resources.files(import_module('namespacedata01'))
174+
resources
175+
.files(import_module('namespacedata01'))
175176
.joinpath('binary.file')
176177
.is_file()
177178
)

0 commit comments

Comments
 (0)