| 38 | if 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 | |
| 93 | else: |
| 94 |
no outgoing calls
searching dependent graphs…