Skip to content

Commit 59e80d1

Browse files
committed
perf: ⚡️ change find_spec -> classmethod
1 parent 32db20c commit 59e80d1

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

pyencrypt/encrypt.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@ def _encrypt_file(
3333
def can_encrypt(path: Path) -> bool:
3434
if path.name in NOT_ALLOWED_ENCRYPT_FILES:
3535
return False
36-
if "management/commands/" in path.as_posix():
37-
return False
3836
if path.suffix != ".py":
3937
return False
4038
return True

pyencrypt/loader.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,9 @@ def get_data(self, path: _Path) -> bytes:
7373

7474

7575
class EncryptFileFinder(abc.MetaPathFinder, Base):
76+
@classmethod
7677
def find_spec(
77-
self, fullname: str, path: Sequence[_Path], target: types.ModuleType = None
78+
cls, fullname: str, path: Sequence[_Path], target: types.ModuleType = None
7879
) -> ModuleSpec:
7980
if path:
8081
if isinstance(path, _NamespacePath):
@@ -92,6 +93,10 @@ def find_spec(
9293
loader = EncryptFileLoader(file_path)
9394
return spec_from_loader(name=fullname, loader=loader, origin="origin-encrypt")
9495

96+
@classmethod
97+
def invalidate_caches(cls):
98+
pass
99+
95100

96101
# TODO: generate randomly AES Class
97-
sys.meta_path.insert(0, EncryptFileFinder())
102+
sys.meta_path.insert(0, EncryptFileFinder)

0 commit comments

Comments
 (0)