diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 52a5f68..6f916f0 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -19,3 +19,14 @@ repos: - id: ruff args: [ --fix ] - id: ruff-format + - repo: https://github.com/pre-commit/mirrors-mypy + rev: v1.10.1 + hooks: + - id: mypy + exclude: | + (?x)( + tests/.* + | docs/.* + ) + additional_dependencies: + - "types-setuptools" diff --git a/src/wrapt/decorators.py b/src/wrapt/decorators.py index ede087d..41459b7 100644 --- a/src/wrapt/decorators.py +++ b/src/wrapt/decorators.py @@ -512,4 +512,4 @@ def __exit__(self, *args): return _FinalDecorator(wrapped=wrapped, wrapper=_synchronized_wrapper) -synchronized._synchronized_meta_lock = Lock() +setattr(synchronized, '_synchronized_meta_lock', Lock()) diff --git a/src/wrapt/importer.py b/src/wrapt/importer.py index a5329ca..2418f9d 100644 --- a/src/wrapt/importer.py +++ b/src/wrapt/importer.py @@ -6,6 +6,7 @@ from importlib.util import find_spec import sys import threading +from typing import Callable from .__wrapt__ import ObjectProxy @@ -15,7 +16,7 @@ # module will be truncated but the list left in the dictionary. This # acts as a flag to indicate that the module had already been imported. -_post_import_hooks = {} +_post_import_hooks: dict[str, list[Callable[[object], object]]] = {} _post_import_hooks_init = False _post_import_hooks_lock = threading.RLock() diff --git a/src/wrapt/wrappers.py b/src/wrapt/wrappers.py index 5446365..1631375 100644 --- a/src/wrapt/wrappers.py +++ b/src/wrapt/wrappers.py @@ -337,7 +337,7 @@ def __imod__(self, other): self.__wrapped__ %= other return self - def __ipow__(self, other): + def __ipow__(self, other, *args): self.__wrapped__ **= other return self