Skip to content

fix(registry): clear the get_upath_class cache for every newly registered protocol - #614

Open
MikeFTV wants to merge 1 commit into
fsspec:mainfrom
MikeFTV:fix/registry-cache-clear
Open

MikeFTV wants to merge 1 commit into
fsspec:mainfrom
MikeFTV:fix/registry-cache-clear

Conversation

@MikeFTV

@MikeFTV MikeFTV commented Dec 5, 2026

Copy link
Copy Markdown

Why

_Registry.__setitem__ only cleared the get_upath_class() cache when the protocol was already registered. A protocol looked up before it was registered stays cached as None:

>>> get_upath_class("myproto", fallback=False)  # None
>>> register_implementation("myproto", MyPath)
>>> get_upath_class("myproto", fallback=False)  # still None

What changes

  • upath/registry.py: __setitem__ now always clears the get_upath_class and _get_implementation_protocols caches after storing the value. Registrations are rare, so clearing every time costs nothing noticeable.
  • upath/tests/test_registry.py: test_register_implementation_after_failed_lookup looks a protocol up, registers it, and looks it up again.
  • CHANGELOG.md: entry under Unreleased / Fixed.

This does not touch the concurrent register_implementation(..., clobber=True) race in #613.

Tests

  • New test on main: 1 failed, 38 passed (assert None is <class ...LateProtoPath>); with the fix: 39 passed in upath/tests/test_registry.py.
  • Full pytest upath (Python 3.11): 4769 passed and 49 failed on main, 4770 passed and the same 49 failed with the fix. The failures are network-dependent cases (test_github.py and a few others) that fail the same way on main; test_pydantic.py was left out because pydantic is not installed here.
  • ruff format --check and mypy upath/registry.py: clean.

Closes #612

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

get_upath_class() keeps returning None for protocols registered after a lookup

1 participant