File tree Expand file tree Collapse file tree 6 files changed +40
-16
lines changed
vcs-versioning/src/vcs_versioning Expand file tree Collapse file tree 6 files changed +40
-16
lines changed Original file line number Diff line number Diff line change 22
33from __future__ import annotations
44
5+ import os
6+ from typing import TypeAlias
7+
8+ # Path type for accepting both strings and PathLike objects
9+ PathT : TypeAlias = os .PathLike [str ] | str
10+
511
612def normalize_path_for_assertion (path : str ) -> str :
713 """Normalize path separators for cross-platform assertions.
@@ -63,3 +69,23 @@ def assert_path_endswith(
6369def compute_path_prefix (full_path : str , suffix_path : str ) -> str :
6470 """Legacy alias - use strip_path_suffix instead."""
6571 return strip_path_suffix (full_path , suffix_path )
72+
73+
74+ def norm_real (path : PathT ) -> str :
75+ """Normalize and resolve a path (combining normcase and realpath).
76+
77+ This combines os.path.normcase() and os.path.realpath() to produce
78+ a canonical path string that is normalized for the platform and has
79+ all symbolic links resolved.
80+
81+ Args:
82+ path: The path to normalize and resolve
83+
84+ Returns:
85+ The normalized, resolved absolute path
86+
87+ Examples:
88+ >>> norm_real("/path/to/../to/file.txt") # doctest: +SKIP
89+ '/path/to/file.txt'
90+ """
91+ return os .path .normcase (os .path .realpath (path ))
Original file line number Diff line number Diff line change 66from typing import TypeGuard
77
88from .. import _types as _t
9+ from .._compat import norm_real
910from .._entrypoints import entry_points
10- from ._pathtools import norm_real
1111
1212log = logging .getLogger ("vcs_versioning.file_finder" )
1313
Original file line number Diff line number Diff line change 77from typing import IO
88
99from .. import _types as _t
10- from .._compat import strip_path_suffix
10+ from .._compat import norm_real , strip_path_suffix
1111from .._integration import data_from_mime
1212from .._run_cmd import run as _run
1313from . import is_toplevel_acceptable , scm_find_files
14- from ._pathtools import norm_real
1514
1615log = logging .getLogger (__name__ )
1716
Original file line number Diff line number Diff line change 66
77from .. import _types as _t
88from .._backends ._hg import run_hg
9+ from .._compat import norm_real
910from .._integration import data_from_mime
1011from . import is_toplevel_acceptable , scm_find_files
11- from ._pathtools import norm_real
1212
1313log = logging .getLogger (__name__ )
1414
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 11from __future__ import annotations
22
3- import os
43from collections .abc import Callable , Sequence
54from typing import TYPE_CHECKING , TypeAlias
65
76if TYPE_CHECKING :
87 from . import _version_schemes as version
98
10- PathT : TypeAlias = os .PathLike [str ] | str
9+ # Re-export from _compat for backward compatibility
10+ from ._compat import PathT as PathT # noqa: PLC0414
11+
12+ __all__ = [
13+ "PathT" ,
14+ "CMD_TYPE" ,
15+ "VERSION_SCHEME" ,
16+ "VERSION_SCHEMES" ,
17+ "SCMVERSION" ,
18+ "GIT_PRE_PARSE" ,
19+ ]
1120
1221CMD_TYPE : TypeAlias = Sequence [PathT ] | str
1322
You can’t perform that action at this time.
0 commit comments