Skip to content

Commit b6925ec

Browse files
committed
internal/private_path(refactor[typing]): Clean up lint and typing
1 parent e280d1f commit b6925ec

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/vcspull/_internal/private_path.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,13 @@
44
import pathlib
55
import typing as t
66

7-
class PrivatePath(type(pathlib.Path())):
7+
if t.TYPE_CHECKING:
8+
PrivatePathBase = pathlib.Path
9+
else:
10+
PrivatePathBase = type(pathlib.Path())
11+
12+
13+
class PrivatePath(PrivatePathBase):
814
"""Path subclass that hides the user's home directory in textual output.
915
1016
The class behaves like :class:`pathlib.Path`, but normalizes string and
@@ -22,14 +28,14 @@ class PrivatePath(type(pathlib.Path())):
2228
PrivatePath('~/projects/vcspull')
2329
>>> str(PrivatePath("/tmp/example"))
2430
'/tmp/example'
25-
>>> f\"build dir: {PrivatePath(home / 'build')}\"
31+
>>> f'build dir: {PrivatePath(home / "build")}'
2632
'build dir: ~/build'
27-
>>> \"{}\".format(PrivatePath(home / 'notes.txt'))
33+
>>> '{}'.format(PrivatePath(home / 'notes.txt'))
2834
'~/notes.txt'
2935
"""
3036

3137
def __new__(cls, *args: t.Any, **kwargs: t.Any) -> PrivatePath:
32-
return t.cast(PrivatePath, super().__new__(cls, *args, **kwargs))
38+
return super().__new__(cls, *args, **kwargs)
3339

3440
@classmethod
3541
def _collapse_home(cls, value: str) -> str:

0 commit comments

Comments
 (0)