From f25500af22d56e94878344044c20acfa63796f49 Mon Sep 17 00:00:00 2001 From: wesselb Date: Fri, 28 Jun 2024 17:04:12 +0000 Subject: [PATCH] deploy: 595690e2373ef5aaaffa031fd1318e0c34b14965 --- _modules/plum/repr.html | 6 ++++-- _modules/plum/signature.html | 32 +++++++++++++++----------------- api.html | 4 ++-- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/_modules/plum/repr.html b/_modules/plum/repr.html index 2663651..19c66ea 100644 --- a/_modules/plum/repr.html +++ b/_modules/plum/repr.html @@ -342,7 +342,7 @@

Source code for plum.repr

 import types
 import typing
 from functools import partial
-from typing import Any, Callable, Dict, Iterable, Optional
+from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar
 
 import rich
 from rich.color import Color
@@ -357,6 +357,8 @@ 

Source code for plum.repr

     "rich_repr",
 ]
 
+T = TypeVar("T")
+
 path_style = Style(color=Color.from_ansi(7))
 file_style = Style(bold=True, underline=True)
 
@@ -540,7 +542,7 @@ 

Source code for plum.repr

     return data
 
 
-
[docs]def rich_repr(cls: Optional[type] = None, str: bool = False): +
[docs]def rich_repr(cls: Optional[Type[T]] = None, str: bool = False) -> Type[T]: """Class decorator defining a `__repr__` method that calls :mod:`rich.` This also sets `_repr_mimebundle_` for better rendering in Jupyter. diff --git a/_modules/plum/signature.html b/_modules/plum/signature.html index 0d303e2..b0270be 100644 --- a/_modules/plum/signature.html +++ b/_modules/plum/signature.html @@ -338,11 +338,11 @@

Source code for plum.signature

 import inspect
 import operator
-import typing
 from copy import copy
-from typing import Callable, List, Set, Tuple, Union
+from typing import Any, Callable, ClassVar, List, Set, Tuple, Union
 
 from rich.segment import Segment
+from typing_extensions import Self
 
 import beartype.door
 from beartype.peps import resolve_pep563 as beartype_resolve_pep563
@@ -379,17 +379,17 @@ 

Source code for plum.signature

         is_faithful (bool): Whether this signature only uses faithful types.
     """
 
-    _default_varargs = Missing
-    _default_precedence = 0
+    _default_varargs: ClassVar = Missing
+    _default_precedence: ClassVar[int] = 0
 
-    __slots__ = ("types", "varargs", "precedence", "is_faithful")
+    __slots__: Tuple[str, ...] = ("types", "varargs", "precedence", "is_faithful")
 
     def __init__(
         self,
         *types: Tuple[TypeHint, ...],
         varargs: OptionalType = _default_varargs,
         precedence: int = _default_precedence,
-    ):
+    ) -> None:
         """Instantiate a signature, which contains exactly the information necessary for
         dispatch.
 
@@ -428,17 +428,15 @@ 

Source code for plum.signature

     def has_varargs(self) -> bool:
         return self.varargs is not Missing
 
-    def __copy__(self):
+    def __copy__(self) -> Self:
         cls = type(self)
         copy = cls.__new__(cls)
+        for attr in self.__slots__:
+            setattr(copy, attr, getattr(self, attr))
 
-        copy.types = self.types
-        copy.varargs = self.varargs
-        copy.precedence = self.precedence
-        copy.is_faithful = self.is_faithful
         return copy
 
-    def __rich_console__(self, console, options):
+    def __rich_console__(self, console, options) -> Segment:
         yield Segment("Signature(")
         show_comma = True
         if self.types:
@@ -453,7 +451,7 @@ 

Source code for plum.signature

             yield Segment("precedence=" + repr(self.precedence))
         yield Segment(")")
 
-    def __eq__(self, other):
+    def __eq__(self, other: Any) -> bool:
         if isinstance(other, Signature):
             return (
                 self.types,
@@ -486,7 +484,7 @@ 

Source code for plum.signature

         else:
             return self.types
- def __le__(self, other) -> bool: + def __le__(self, other: "Signature") -> bool: # If the number of types of the signatures are unequal, then the signature # with the fewer number of types must be expanded using variable arguments. if not ( @@ -564,7 +562,7 @@

Source code for plum.signature

         else:
             return False
 
-
[docs] def match(self, values) -> bool: +
[docs] def match(self, values: Tuple) -> bool: """Check whether values match the signature. Args: @@ -636,7 +634,7 @@

Source code for plum.signature

         return mismatches, varargs_matched
-def inspect_signature(f) -> inspect.Signature: +def inspect_signature(f: Callable) -> inspect.Signature: """Wrapper of :func:`inspect.signature` which adds support for certain non-function objects. @@ -690,7 +688,7 @@

Source code for plum.signature

 
         # Parse and resolve annotation.
         if p.annotation is inspect.Parameter.empty:
-            annotation = typing.Any
+            annotation = Any
         else:
             annotation = resolve_type_hint(p.annotation)
 
diff --git a/api.html b/api.html
index 39510cb..625e875 100644
--- a/api.html
+++ b/api.html
@@ -652,7 +652,7 @@ 

Application Programming Interface
-match(values) bool[source]#
+match(values: Tuple) bool[source]#

Check whether values match the signature.

Parameters:
@@ -1468,7 +1468,7 @@

Application Programming Interface
-plum.repr.rich_repr(cls: Optional[type] = None, str: bool = False)[source]#
+plum.repr.rich_repr(cls: Optional[Type[T]] = None, str: bool = False) Type[T][source]#

Class decorator defining a __repr__ method that calls rich.

This also sets _repr_mimebundle_ for better rendering in Jupyter.