Skip to content

Commit

Permalink
perf: ⚡️ change find_spec -> classmethod
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhaoQi99 committed Nov 5, 2024
1 parent 32db20c commit e5184e0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
2 changes: 0 additions & 2 deletions pyencrypt/encrypt.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ def _encrypt_file(
def can_encrypt(path: Path) -> bool:
if path.name in NOT_ALLOWED_ENCRYPT_FILES:
return False
if "management/commands/" in path.as_posix():
return False
if path.suffix != ".py":
return False
return True
Expand Down
5 changes: 3 additions & 2 deletions pyencrypt/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,9 @@ def get_data(self, path: _Path) -> bytes:


class EncryptFileFinder(abc.MetaPathFinder, Base):
@classmethod
def find_spec(
self, fullname: str, path: Sequence[_Path], target: types.ModuleType = None
cls, fullname: str, path: Sequence[_Path], target: types.ModuleType = None
) -> ModuleSpec:
if path:
if isinstance(path, _NamespacePath):
Expand All @@ -94,4 +95,4 @@ def find_spec(


# TODO: generate randomly AES Class
sys.meta_path.insert(0, EncryptFileFinder())
sys.meta_path.insert(0, EncryptFileFinder)

0 comments on commit e5184e0

Please sign in to comment.