Jelajahi Sumber

__init__.py: Add typing

Jelmer Vernooij 3 bulan lalu
induk
melakukan
c7da6dd2bf
1 mengubah file dengan 8 tambahan dan 2 penghapusan
  1. 8 2
      dulwich/__init__.py

+ 8 - 2
dulwich/__init__.py

@@ -23,17 +23,23 @@
 
 """Python implementation of the Git file formats and protocols."""
 
+from typing import Any, Callable, Optional, TypeVar
+
 __version__ = (0, 23, 0)
 
 __all__ = ["replace_me"]
 
+F = TypeVar("F", bound=Callable[..., Any])
+
 try:
     from dissolve import replace_me
 except ImportError:
     # if dissolve is not installed, then just provide a basic implementation
     # of its replace_me decorator
-    def replace_me(since=None, remove_in=None):
-        def decorator(func):
+    def replace_me(
+        since: Optional[str] = None, remove_in: Optional[str] = None
+    ) -> Callable[[F], F]:
+        def decorator(func: F) -> F:
             import warnings
 
             m = f"{func.__name__} is deprecated"