99from datetime import datetime , timedelta
1010from typing import Callable , Dict , Generator , List , Literal , Set , Tuple , Union
1111
12- from pathlibutil .base import BasePath , _Path
12+ from pathlibutil .base import BasePath
1313from pathlibutil .types import ByteInt , StatResult , TimeInt , _stat_result , byteint
1414
1515
@@ -130,7 +130,7 @@ def verify(
130130
131131 return True
132132
133- def __enter__ (self ) -> _Path :
133+ def __enter__ (self ) -> "Path" :
134134 """
135135 Contextmanager to changes the current working directory.
136136 """
@@ -175,7 +175,7 @@ def size(self, **kwargs) -> ByteInt:
175175
176176 return super ().stat (** kwargs ).st_size
177177
178- def copy (self , dst : str , exist_ok : bool = True , ** kwargs ) -> _Path :
178+ def copy (self , dst : str , exist_ok : bool = True , ** kwargs ) -> "Path" :
179179 """
180180 Copies the file or directory to a destination directory, if it is missing it
181181 will be created.
@@ -227,7 +227,7 @@ def delete(
227227
228228 shutil .rmtree (self , ** kwargs )
229229
230- def move (self , dst : str ) -> _Path :
230+ def move (self , dst : str ) -> "Path" :
231231 """
232232 Moves the file or directory into the destination directory.
233233
@@ -247,7 +247,7 @@ def move(self, dst: str) -> _Path:
247247 return self .__class__ (_path )
248248
249249 @staticmethod
250- def _find_archive_format (filename : _Path ) -> str :
250+ def _find_archive_format (filename : "Path" ) -> str :
251251 """
252252 Searches for a file the correct archive format.
253253 """
@@ -273,7 +273,7 @@ def _register_format(cls, format: str) -> None:
273273
274274 def make_archive (
275275 self , archivename : str , * , exists_ok : bool = False , ** kwargs
276- ) -> _Path :
276+ ) -> "Path" :
277277 """
278278 Creates an archive file (eg. zip) and returns the path to the archive.
279279
@@ -296,7 +296,7 @@ def make_archive(
296296 Path('test.zpy')
297297 """
298298
299- def _archive_exists (file : str , exists_ok : bool ) -> _Path :
299+ def _archive_exists (file : str , exists_ok : bool ) -> "Path" :
300300 """
301301 Returns a `Path` object of the archive file or raises a `FileExistsError`
302302 If `exists_ok` is `True` the file will be deleted.
@@ -311,7 +311,7 @@ def _archive_exists(file: str, exists_ok: bool) -> _Path:
311311
312312 return file
313313
314- def _archive_filename (expect : Path , real : str ) -> _Path :
314+ def _archive_filename (expect : Path , real : str ) -> "Path" :
315315 """
316316 Check if the expected archive filename matches the real filename.
317317 If not try to rename the real filename.
@@ -346,7 +346,7 @@ def _archive_filename(expect: Path, real: str) -> _Path:
346346
347347 return _archive_filename (_filename , _archive )
348348
349- def unpack_archive (self , extract_dir : str , ** kwargs ) -> _Path :
349+ def unpack_archive (self , extract_dir : str , ** kwargs ) -> "Path" :
350350 """
351351 Unpacks an archive file (eg. zip) into a directory and returns the path to the
352352 extracted files.
@@ -405,7 +405,7 @@ def stat(self, **kwargs) -> _stat_result:
405405 """
406406 return StatResult (super ().stat (** kwargs ))
407407
408- def with_suffix (self , suffix : Union [str , List [str ]]) -> _Path :
408+ def with_suffix (self , suffix : Union [str , List [str ]]) -> "Path" :
409409 """
410410 Return a new `Path` with changed suffix or remove it when its an empty
411411 string.
@@ -444,8 +444,8 @@ def with_suffix(self, suffix: Union[str, List[str]]) -> _Path:
444444 return super (self .__class__ , stem ).with_suffix (suffix )
445445
446446 def relative_to (
447- self , * other : Union [str , _Path ], walk_up : Union [bool , int ] = False
448- ) -> _Path :
447+ self , * other : Union [str , "Path" ], walk_up : Union [bool , int ] = False
448+ ) -> "Path" :
449449 """
450450 Return the relative path to another path identified by the passed
451451 arguments. If the operation is not possible (because this is not
@@ -485,7 +485,7 @@ def relative_to(
485485 return relative
486486
487487 @classmethod
488- def cwd (cls , * , frozen : Literal [True , False , "_MEIPASS" ] = False ) -> _Path :
488+ def cwd (cls , * , frozen : Literal [True , False , "_MEIPASS" ] = False ) -> "Path" :
489489 """
490490 Return a `Path` object representing the current working directory.
491491
@@ -536,7 +536,7 @@ def run(cmd: str) -> str:
536536 except Exception :
537537 return {}
538538
539- def _resolve_unc (self ) -> _Path :
539+ def _resolve_unc (self ) -> "Path" :
540540 """
541541 Resolve UNC paths to mapped network drives.
542542 """
@@ -549,7 +549,7 @@ def _resolve_unc(self) -> _Path:
549549 except KeyError :
550550 return self
551551
552- def resolve (self , strict : bool = False , unc : bool = True ) -> _Path :
552+ def resolve (self , strict : bool = False , unc : bool = True ) -> "Path" :
553553 """
554554 Make the path absolute, resolving all symlinks on the way and also normalizing
555555 it.
@@ -579,7 +579,7 @@ def walk(
579579 top_down : bool = True ,
580580 on_error : Callable [[OSError ], object ] = None ,
581581 follow_symlinks : bool = False ,
582- ) -> Generator [Tuple [_Path , List [str ], List [str ]], None , None ]:
582+ ) -> Generator [Tuple ["Path" , List [str ], List [str ]], None , None ]:
583583 """
584584 Walks the directory tree and yields a 3-tuple of (dirpath, dirnames, filenames).
585585 """
@@ -602,9 +602,9 @@ def iterdir(
602602 self ,
603603 * ,
604604 recursive : Union [bool , int ] = False ,
605- exclude_dirs : Callable [[_Path ], bool ] = None ,
605+ exclude_dirs : Callable [["Path" ], bool ] = None ,
606606 ** kwargs ,
607- ) -> Generator [_Path , None , None ]:
607+ ) -> Generator ["Path" , None , None ]:
608608 """
609609 Iterates over the files in the directory.
610610
@@ -616,7 +616,7 @@ def iterdir(
616616 `exclude_dirs`, e.g.
617617
618618 ```python
619- def exclude_version_control(dirpath: _Path ) -> bool:
619+ def exclude_version_control(dirpath: "Path" ) -> bool:
620620 return dirpath.name in (".git", ".svn", ".hg", ".bzr", "CVS")
621621 ```
622622 """
@@ -660,7 +660,7 @@ def expand(
660660 cls ,
661661 * files : str ,
662662 duplicates : bool = True ,
663- ) -> Generator [_Path , None , None ]:
663+ ) -> Generator ["Path" , None , None ]:
664664 """
665665 Yields only Path object of file names that exists. Supports glob patterns in
666666 filename as wildcards.
0 commit comments