Skip to content

Commit

Permalink
Fix pyright with thread local and unused import
Browse files Browse the repository at this point in the history
  • Loading branch information
emdoyle committed Feb 10, 2024
1 parent 6b660f1 commit 8a81f3c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
7 changes: 6 additions & 1 deletion modguard/filesystem/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ class FileInfo:

# Thread-local file cache to avoid going to disk as much as possible
thread_local = threading.local()
# Cannot type-hint non-self attributes (https://github.com/python/mypy/issues/2388)
# cwd: str
thread_local.cwd = os.getcwd()
# file_caches_by_cwd: defaultdict[str, dict[str, FileInfo]]
thread_local.file_caches_by_cwd = defaultdict(dict)


Expand All @@ -38,7 +41,9 @@ def _get_file_cache() -> dict[str, FileInfo]:
if not hasattr(thread_local, "file_caches_by_cwd"):
print("reset file cache")
thread_local.file_caches_by_cwd = defaultdict(dict)
file_caches_by_cwd = thread_local.file_caches_by_cwd
file_caches_by_cwd: defaultdict[
str, dict[str, FileInfo]
] = thread_local.file_caches_by_cwd # type: ignore
return file_caches_by_cwd[get_cwd()]


Expand Down
1 change: 0 additions & 1 deletion modguard/parsing/imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

from modguard import filesystem as fs
from modguard.public import public
from modguard.errors import ModguardParseError


@dataclass
Expand Down

0 comments on commit 8a81f3c

Please sign in to comment.