Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- upath: **BREAKING** drop support for Python 3.9 and 3.10, which reached their end of life, and require Python>=3.11 (#544)
- upath: remove backports for Python<3.11, `typing_extensions` is no longer needed for resolving type hints at runtime

### Fixed
- upath.registry: clear the `get_upath_class()` cache whenever a protocol is registered, so a protocol looked up before it was registered no longer keeps returning `None` (#612)

## [0.3.11] - 2026-11-24

### Added
Expand Down
5 changes: 2 additions & 3 deletions upath/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,9 @@ def __setitem__(self, item: str, value: type[upath.UPath] | str) -> None:
raise ValueError(
f"expected UPath subclass or FQN-string, got: {type(value).__name__!r}"
)
if not item or item in self._m:
get_upath_class.cache_clear() # type: ignore[attr-defined]
_get_implementation_protocols.cache_clear() # type: ignore[attr-defined]
self._m[item] = value
get_upath_class.cache_clear() # type: ignore[attr-defined]
_get_implementation_protocols.cache_clear() # type: ignore[attr-defined]

def __delitem__(self, __v: str) -> None:
raise NotImplementedError("removal is unsupported")
Expand Down
11 changes: 11 additions & 0 deletions upath/tests/test_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,17 @@ class MyProtoPath(UPath):
assert get_upath_class("myproto") is MyProtoPath


def test_register_implementation_after_failed_lookup():
class LateProtoPath(UPath):
pass

assert get_upath_class("lateproto", fallback=False) is None

register_implementation("lateproto", LateProtoPath)

assert get_upath_class("lateproto", fallback=False) is LateProtoPath


def test_register_implementation_wrong_input():
with pytest.raises(TypeError):
register_implementation(None, UPath) # type: ignore
Expand Down