Skip to content

Commit 977544a

Browse files
authored
upath.core: (backcompat) TypeError on protocol incompatibility (fsspec#540)
1 parent bc25303 commit 977544a

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

upath/core.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,18 @@ class _IncompatibleProtocolError(TypeError, ValueError):
121121
"""switch to TypeError for incompatible protocols in a backward compatible way.
122122
123123
!!! Do not use this exception directly !!!
124+
Catch TypeError instead, if you need to handle incompatible protocol errors.
125+
126+
We'll do the switch in a future major release.
124127
"""
125128

129+
# evil: make this look like a built-in TypeError
130+
__module__ = "builtins"
131+
__qualname__ = "TypeError"
132+
133+
def __repr__(self) -> str:
134+
return f"TypeError({', '.join(map(repr, self.args))})"
135+
126136

127137
class _UPathMeta(ABCMeta):
128138
"""metaclass for UPath to customize instance creation

0 commit comments

Comments
 (0)