Skip to content

Commit

Permalink
Merge pull request #32 from pawamoy/patch-1
Browse files Browse the repository at this point in the history
Fix invalidate_caches type error
  • Loading branch information
pfmoore committed Jul 12, 2023
2 parents 38f210e + 41fe85e commit c86b9c8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/editables/redirector.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,11 @@ def install(cls) -> None:
break
else:
sys.meta_path.append(cls)

@classmethod
def invalidate_caches(cls) -> None:
# importlib.invalidate_caches calls finders' invalidate_caches methods,
# and since we install this meta path finder as a class rather than an instance,
# we have to override the inherited invalidate_caches method (using self)
# as a classmethod instead
pass
8 changes: 8 additions & 0 deletions tests/test_redirects.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import contextlib
import importlib
import sys

from editables.redirector import RedirectingFinder as F
Expand Down Expand Up @@ -81,3 +82,10 @@ def test_redirects(tmp_path):
import pkg.sub

assert pkg.sub.val == 42


def test_cache_invalidation():
F.install()
# assert that the finder matches importlib's expectations
# see https://github.com/pfmoore/editables/issues/31
importlib.invalidate_caches()

0 comments on commit c86b9c8

Please sign in to comment.