Let us walk on the 3-isogeny graph
Loading...
Searching...
No Matches
pip._vendor.rich.repr Namespace Reference

Data Structures

class  Foo
 
class  ReprError
 

Functions

Type[Tauto (Optional[Type[T]] cls)
 
Callable[[Type[T]], Type[T]] auto (*bool angular=False)
 
Union[Type[T], Callable[[Type[T]], Type[T]]] auto (Optional[Type[T]] cls=None, *Optional[bool] angular=None)
 
Type[Trich_repr (Optional[Type[T]] cls)
 
Callable[[Type[T]], Type[T]] rich_repr (*bool angular=False)
 
Union[Type[T], Callable[[Type[T]], Type[T]]] rich_repr (Optional[Type[T]] cls=None, *bool angular=False)
 

Variables

 T = TypeVar("T")
 
 Result = Iterable[Union[Any, Tuple[Any], Tuple[str, Any], Tuple[str, Any, Any]]]
 
 RichReprResult = Result
 
 foo
 
 console = Console()
 
 width
 
 angular
 

Function Documentation

◆ auto() [1/3]

Callable[[Type[T]], Type[T]] auto ( *bool   angular = False)

Definition at line 33 of file repr.py.

33def auto(*, angular: bool = False) -> Callable[[Type[T]], Type[T]]:
34 ...
35
36

◆ auto() [2/3]

Type[T] auto ( Optional[Type[T]]  cls)

Definition at line 28 of file repr.py.

28def auto(cls: Optional[Type[T]]) -> Type[T]:
29 ...
30
31
32@overload

Referenced by pip._vendor.rich.repr.rich_repr().

Here is the caller graph for this function:

◆ auto() [3/3]

Union[Type[T], Callable[[Type[T]], Type[T]]] auto ( Optional[Type[T]]   cls = None,
*Optional[bool]   angular = None 
)
Class decorator to create __repr__ from __rich_repr__

Definition at line 37 of file repr.py.

39) -> Union[Type[T], Callable[[Type[T]], Type[T]]]:
40 """Class decorator to create __repr__ from __rich_repr__"""
41
42 def do_replace(cls: Type[T], angular: Optional[bool] = None) -> Type[T]:
43 def auto_repr(self: T) -> str:
44 """Create repr string from __rich_repr__"""
45 repr_str: List[str] = []
46 append = repr_str.append
47
48 angular: bool = getattr(self.__rich_repr__, "angular", False) # type: ignore[attr-defined]
49 for arg in self.__rich_repr__(): # type: ignore[attr-defined]
50 if isinstance(arg, tuple):
51 if len(arg) == 1:
52 append(repr(arg[0]))
53 else:
54 key, value, *default = arg
55 if key is None:
56 append(repr(value))
57 else:
58 if default and default[0] == value:
59 continue
60 append(f"{key}={value!r}")
61 else:
62 append(repr(arg))
63 if angular:
64 return f"<{self.__class__.__name__} {' '.join(repr_str)}>"
65 else:
66 return f"{self.__class__.__name__}({', '.join(repr_str)})"
67
68 def auto_rich_repr(self: Type[T]) -> Result:
69 """Auto generate __rich_rep__ from signature of __init__"""
70 try:
71 signature = inspect.signature(self.__init__)
72 for name, param in signature.parameters.items():
74 yield getattr(self, name)
75 elif param.kind in (
78 ):
80 yield getattr(self, param.name)
81 else:
83 except Exception as error:
84 raise ReprError(
85 f"Failed to auto generate __rich_repr__; {error}"
86 ) from None
87
88 if not hasattr(cls, "__rich_repr__"):
89 auto_rich_repr.__doc__ = "Build a rich repr"
90 cls.__rich_repr__ = auto_rich_repr # type: ignore[attr-defined]
91
92 auto_repr.__doc__ = "Return repr(self)"
93 cls.__repr__ = auto_repr # type: ignore[assignment]
94 if angular is not None:
95 cls.__rich_repr__.angular = angular # type: ignore[attr-defined]
96 return cls
97
98 if cls is None:
99 return partial(do_replace, angular=angular)
100 else:
101 return do_replace(cls, angular=angular)
102
103
104@overload
for i

References i.

◆ rich_repr() [1/3]

Callable[[Type[T]], Type[T]] rich_repr ( *bool   angular = False)

Definition at line 110 of file repr.py.

110def rich_repr(*, angular: bool = False) -> Callable[[Type[T]], Type[T]]:
111 ...
112
113

◆ rich_repr() [2/3]

Type[T] rich_repr ( Optional[Type[T]]  cls)

Definition at line 105 of file repr.py.

105def rich_repr(cls: Optional[Type[T]]) -> Type[T]:
106 ...
107
108
109@overload

◆ rich_repr() [3/3]

Union[Type[T], Callable[[Type[T]], Type[T]]] rich_repr ( Optional[Type[T]]   cls = None,
*bool   angular = False 
)

Definition at line 114 of file repr.py.

116) -> Union[Type[T], Callable[[Type[T]], Type[T]]]:
117 if cls is None:
118 return auto(angular=angular)
119 else:
120 return auto(cls)
121
122

References pip._vendor.rich.repr.auto().

Here is the call graph for this function:

Variable Documentation

◆ angular

angular

Definition at line 144 of file repr.py.

◆ console

console = Console()

Definition at line 135 of file repr.py.

◆ foo

foo

Definition at line 132 of file repr.py.

◆ Result

Result = Iterable[Union[Any, Tuple[Any], Tuple[str, Any], Tuple[str, Any, Any]]]

Definition at line 19 of file repr.py.

◆ RichReprResult

RichReprResult = Result

Definition at line 20 of file repr.py.

◆ T

T = TypeVar("T")

Definition at line 16 of file repr.py.

◆ width

width

Definition at line 140 of file repr.py.