MCPcopy
hub / github.com/sphinx-doc/sphinx / _StrPath

Class _StrPath

sphinx/util/_pathlib.py:40–91  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

38if sys.platform == 'win32':
39
40 class _StrPath(WindowsPath):
41 def replace( # type: ignore[override]
42 self, old: str, new: str, count: int = -1, /
43 ) -> str:
44 # replace exists in both Path and str;
45 # in Path it makes filesystem changes, so we use the safer str version
46 warnings.warn(_MSG, RemovedInSphinx10Warning, stacklevel=2)
47 return self.__str__().replace(old, new, count) # NoQA: PLC2801
48
49 def __getattr__(self, item: str) -> Any:
50 if item in _STR_METHODS:
51 warnings.warn(_MSG, RemovedInSphinx10Warning, stacklevel=2)
52 return getattr(self.__str__(), item)
53 msg = f'{_PATH_NAME!r} has no attribute {item!r}'
54 raise AttributeError(msg)
55
56 def __add__(self, other: str) -> str:
57 warnings.warn(_MSG, RemovedInSphinx10Warning, stacklevel=2)
58 return self.__str__() + other
59
60 def __radd__(self, other: str) -> str:
61 warnings.warn(_MSG, RemovedInSphinx10Warning, stacklevel=2)
62 return other + self.__str__()
63
64 def __bool__(self) -> bool:
65 if not self.__str__():
66 warnings.warn(_MSG, RemovedInSphinx10Warning, stacklevel=2)
67 return False
68 return True
69
70 def __contains__(self, item: str) -> bool:
71 warnings.warn(_MSG, RemovedInSphinx10Warning, stacklevel=2)
72 return item in self.__str__()
73
74 def __eq__(self, other: object) -> bool:
75 if isinstance(other, PurePath):
76 return super().__eq__(other)
77 if isinstance(other, str):
78 warnings.warn(_MSG, RemovedInSphinx10Warning, stacklevel=2)
79 return self.__str__() == other
80 return NotImplemented
81
82 def __hash__(self) -> int:
83 return super().__hash__()
84
85 def __getitem__(self, item: int | slice) -> str:
86 warnings.warn(_MSG, RemovedInSphinx10Warning, stacklevel=2)
87 return self.__str__()[item]
88
89 def __len__(self) -> int:
90 warnings.warn(_MSG, RemovedInSphinx10Warning, stacklevel=2)
91 return len(self.__str__())
92
93else:
94

Callers 15

__init__Method · 0.90
__init__Method · 0.90
doc2pathMethod · 0.90
__init__.pyFile · 0.90
_load_builtin_themesMethod · 0.90
add_html_themeMethod · 0.90
__init__Method · 0.90
read_fileMethod · 0.90
get_module_sourceMethod · 0.90
for_fileMethod · 0.90

Calls

no outgoing calls

Tested by 1

Used in the wild real call sites across dependent graphs

searching dependent graphs…