diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index bf5b3f7..73d33e1 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -49,7 +49,6 @@ repos: (?x) ^( | plum/alias\.py - | plum/dispatcher\.py | plum/function\.py | plum/method\.py | plum/parametric\.py diff --git a/plum/autoreload.py b/plum/autoreload.py index 3649132..f17f727 100644 --- a/plum/autoreload.py +++ b/plum/autoreload.py @@ -26,7 +26,7 @@ def _update_instances(old: type, new: type) -> None: type_mapping[k] = v # Since types have changed, clear the cache of everything. - clear_all_cache() # type: ignore[no-untyped-call] + clear_all_cache() _update_instances_original = None diff --git a/plum/dispatcher.py b/plum/dispatcher.py index f81d650..c69c5c2 100644 --- a/plum/dispatcher.py +++ b/plum/dispatcher.py @@ -32,10 +32,10 @@ class Dispatcher: classes: Dict[str, Dict[str, Function]] = field(default_factory=dict) @overload - def __call__(self, method: T, precedence: int = ...) -> T: ... + def __call__(self, method: None, precedence: int) -> Callable[[T], T]: ... @overload - def __call__(self, method: None, precedence: int) -> Callable[[T], T]: ... + def __call__(self, method: T, precedence: int = ...) -> T: ... def __call__( self, method: Optional[T] = None, precedence: int = 0 @@ -130,13 +130,13 @@ def _add_method( f.register(method, signature, precedence) return f - def clear_cache(self): + def clear_cache(self) -> None: """Clear cache.""" for f in self.functions.values(): f.clear_cache() -def clear_all_cache(): +def clear_all_cache() -> None: """Clear all cache, including the cache of subclass checks. This should be called if types are modified.""" for f in Function._instances: