annotate mercurial/thirdparty/attr/__init__.pyi @ 50425:9fa3cda7449e

heptapod: add `.gitattributes` file to improve language detection I am fully aware of the irony.
author Raphaël Gomès <rgomes@octobus.net>
date Wed, 05 Apr 2023 16:09:08 +0200
parents e1c586b9a43c
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
49643
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
1 import sys
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
2
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
3 from typing import (
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
4 Any,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
5 Callable,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
6 ClassVar,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
7 Dict,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
8 Generic,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
9 List,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
10 Mapping,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
11 Optional,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
12 Protocol,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
13 Sequence,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
14 Tuple,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
15 Type,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
16 TypeVar,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
17 Union,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
18 overload,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
19 )
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
20
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
21 # `import X as X` is required to make these public
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
22 from . import converters as converters
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
23 from . import exceptions as exceptions
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
24 from . import filters as filters
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
25 from . import setters as setters
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
26 from . import validators as validators
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
27 from ._cmp import cmp_using as cmp_using
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
28 from ._version_info import VersionInfo
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
29
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
30 __version__: str
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
31 __version_info__: VersionInfo
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
32 __title__: str
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
33 __description__: str
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
34 __url__: str
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
35 __uri__: str
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
36 __author__: str
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
37 __email__: str
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
38 __license__: str
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
39 __copyright__: str
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
40
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
41 _T = TypeVar("_T")
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
42 _C = TypeVar("_C", bound=type)
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
43
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
44 _EqOrderType = Union[bool, Callable[[Any], Any]]
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
45 _ValidatorType = Callable[[Any, Attribute[_T], _T], Any]
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
46 _ConverterType = Callable[[Any], Any]
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
47 _FilterType = Callable[[Attribute[_T], _T], bool]
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
48 _ReprType = Callable[[Any], str]
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
49 _ReprArgType = Union[bool, _ReprType]
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
50 _OnSetAttrType = Callable[[Any, Attribute[Any], Any], Any]
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
51 _OnSetAttrArgType = Union[
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
52 _OnSetAttrType, List[_OnSetAttrType], setters._NoOpType
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
53 ]
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
54 _FieldTransformer = Callable[
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
55 [type, List[Attribute[Any]]], List[Attribute[Any]]
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
56 ]
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
57 # FIXME: in reality, if multiple validators are passed they must be in a list
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
58 # or tuple, but those are invariant and so would prevent subtypes of
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
59 # _ValidatorType from working when passed in a list or tuple.
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
60 _ValidatorArgType = Union[_ValidatorType[_T], Sequence[_ValidatorType[_T]]]
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
61
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
62 # A protocol to be able to statically accept an attrs class.
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
63 class AttrsInstance(Protocol):
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
64 __attrs_attrs__: ClassVar[Any]
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
65
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
66 # _make --
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
67
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
68 NOTHING: object
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
69
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
70 # NOTE: Factory lies about its return type to make this possible:
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
71 # `x: List[int] # = Factory(list)`
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
72 # Work around mypy issue #4554 in the common case by using an overload.
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
73 if sys.version_info >= (3, 8):
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
74 from typing import Literal
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
75 @overload
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
76 def Factory(factory: Callable[[], _T]) -> _T: ...
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
77 @overload
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
78 def Factory(
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
79 factory: Callable[[Any], _T],
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
80 takes_self: Literal[True],
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
81 ) -> _T: ...
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
82 @overload
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
83 def Factory(
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
84 factory: Callable[[], _T],
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
85 takes_self: Literal[False],
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
86 ) -> _T: ...
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
87
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
88 else:
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
89 @overload
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
90 def Factory(factory: Callable[[], _T]) -> _T: ...
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
91 @overload
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
92 def Factory(
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
93 factory: Union[Callable[[Any], _T], Callable[[], _T]],
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
94 takes_self: bool = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
95 ) -> _T: ...
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
96
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
97 # Static type inference support via __dataclass_transform__ implemented as per:
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
98 # https://github.com/microsoft/pyright/blob/1.1.135/specs/dataclass_transforms.md
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
99 # This annotation must be applied to all overloads of "define" and "attrs"
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
100 #
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
101 # NOTE: This is a typing construct and does not exist at runtime. Extensions
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
102 # wrapping attrs decorators should declare a separate __dataclass_transform__
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
103 # signature in the extension module using the specification linked above to
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
104 # provide pyright support.
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
105 def __dataclass_transform__(
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
106 *,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
107 eq_default: bool = True,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
108 order_default: bool = False,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
109 kw_only_default: bool = False,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
110 field_descriptors: Tuple[Union[type, Callable[..., Any]], ...] = (()),
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
111 ) -> Callable[[_T], _T]: ...
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
112
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
113 class Attribute(Generic[_T]):
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
114 name: str
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
115 default: Optional[_T]
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
116 validator: Optional[_ValidatorType[_T]]
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
117 repr: _ReprArgType
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
118 cmp: _EqOrderType
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
119 eq: _EqOrderType
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
120 order: _EqOrderType
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
121 hash: Optional[bool]
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
122 init: bool
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
123 converter: Optional[_ConverterType]
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
124 metadata: Dict[Any, Any]
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
125 type: Optional[Type[_T]]
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
126 kw_only: bool
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
127 on_setattr: _OnSetAttrType
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
128 def evolve(self, **changes: Any) -> "Attribute[Any]": ...
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
129
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
130 # NOTE: We had several choices for the annotation to use for type arg:
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
131 # 1) Type[_T]
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
132 # - Pros: Handles simple cases correctly
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
133 # - Cons: Might produce less informative errors in the case of conflicting
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
134 # TypeVars e.g. `attr.ib(default='bad', type=int)`
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
135 # 2) Callable[..., _T]
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
136 # - Pros: Better error messages than #1 for conflicting TypeVars
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
137 # - Cons: Terrible error messages for validator checks.
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
138 # e.g. attr.ib(type=int, validator=validate_str)
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
139 # -> error: Cannot infer function type argument
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
140 # 3) type (and do all of the work in the mypy plugin)
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
141 # - Pros: Simple here, and we could customize the plugin with our own errors.
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
142 # - Cons: Would need to write mypy plugin code to handle all the cases.
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
143 # We chose option #1.
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
144
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
145 # `attr` lies about its return type to make the following possible:
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
146 # attr() -> Any
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
147 # attr(8) -> int
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
148 # attr(validator=<some callable>) -> Whatever the callable expects.
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
149 # This makes this type of assignments possible:
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
150 # x: int = attr(8)
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
151 #
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
152 # This form catches explicit None or no default but with no other arguments
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
153 # returns Any.
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
154 @overload
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
155 def attrib(
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
156 default: None = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
157 validator: None = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
158 repr: _ReprArgType = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
159 cmp: Optional[_EqOrderType] = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
160 hash: Optional[bool] = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
161 init: bool = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
162 metadata: Optional[Mapping[Any, Any]] = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
163 type: None = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
164 converter: None = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
165 factory: None = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
166 kw_only: bool = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
167 eq: Optional[_EqOrderType] = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
168 order: Optional[_EqOrderType] = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
169 on_setattr: Optional[_OnSetAttrArgType] = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
170 ) -> Any: ...
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
171
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
172 # This form catches an explicit None or no default and infers the type from the
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
173 # other arguments.
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
174 @overload
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
175 def attrib(
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
176 default: None = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
177 validator: Optional[_ValidatorArgType[_T]] = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
178 repr: _ReprArgType = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
179 cmp: Optional[_EqOrderType] = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
180 hash: Optional[bool] = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
181 init: bool = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
182 metadata: Optional[Mapping[Any, Any]] = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
183 type: Optional[Type[_T]] = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
184 converter: Optional[_ConverterType] = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
185 factory: Optional[Callable[[], _T]] = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
186 kw_only: bool = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
187 eq: Optional[_EqOrderType] = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
188 order: Optional[_EqOrderType] = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
189 on_setattr: Optional[_OnSetAttrArgType] = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
190 ) -> _T: ...
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
191
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
192 # This form catches an explicit default argument.
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
193 @overload
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
194 def attrib(
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
195 default: _T,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
196 validator: Optional[_ValidatorArgType[_T]] = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
197 repr: _ReprArgType = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
198 cmp: Optional[_EqOrderType] = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
199 hash: Optional[bool] = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
200 init: bool = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
201 metadata: Optional[Mapping[Any, Any]] = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
202 type: Optional[Type[_T]] = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
203 converter: Optional[_ConverterType] = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
204 factory: Optional[Callable[[], _T]] = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
205 kw_only: bool = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
206 eq: Optional[_EqOrderType] = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
207 order: Optional[_EqOrderType] = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
208 on_setattr: Optional[_OnSetAttrArgType] = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
209 ) -> _T: ...
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
210
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
211 # This form covers type=non-Type: e.g. forward references (str), Any
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
212 @overload
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
213 def attrib(
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
214 default: Optional[_T] = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
215 validator: Optional[_ValidatorArgType[_T]] = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
216 repr: _ReprArgType = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
217 cmp: Optional[_EqOrderType] = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
218 hash: Optional[bool] = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
219 init: bool = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
220 metadata: Optional[Mapping[Any, Any]] = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
221 type: object = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
222 converter: Optional[_ConverterType] = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
223 factory: Optional[Callable[[], _T]] = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
224 kw_only: bool = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
225 eq: Optional[_EqOrderType] = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
226 order: Optional[_EqOrderType] = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
227 on_setattr: Optional[_OnSetAttrArgType] = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
228 ) -> Any: ...
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
229 @overload
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
230 def field(
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
231 *,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
232 default: None = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
233 validator: None = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
234 repr: _ReprArgType = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
235 hash: Optional[bool] = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
236 init: bool = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
237 metadata: Optional[Mapping[Any, Any]] = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
238 converter: None = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
239 factory: None = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
240 kw_only: bool = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
241 eq: Optional[bool] = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
242 order: Optional[bool] = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
243 on_setattr: Optional[_OnSetAttrArgType] = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
244 ) -> Any: ...
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
245
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
246 # This form catches an explicit None or no default and infers the type from the
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
247 # other arguments.
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
248 @overload
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
249 def field(
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
250 *,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
251 default: None = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
252 validator: Optional[_ValidatorArgType[_T]] = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
253 repr: _ReprArgType = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
254 hash: Optional[bool] = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
255 init: bool = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
256 metadata: Optional[Mapping[Any, Any]] = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
257 converter: Optional[_ConverterType] = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
258 factory: Optional[Callable[[], _T]] = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
259 kw_only: bool = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
260 eq: Optional[_EqOrderType] = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
261 order: Optional[_EqOrderType] = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
262 on_setattr: Optional[_OnSetAttrArgType] = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
263 ) -> _T: ...
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
264
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
265 # This form catches an explicit default argument.
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
266 @overload
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
267 def field(
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
268 *,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
269 default: _T,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
270 validator: Optional[_ValidatorArgType[_T]] = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
271 repr: _ReprArgType = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
272 hash: Optional[bool] = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
273 init: bool = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
274 metadata: Optional[Mapping[Any, Any]] = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
275 converter: Optional[_ConverterType] = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
276 factory: Optional[Callable[[], _T]] = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
277 kw_only: bool = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
278 eq: Optional[_EqOrderType] = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
279 order: Optional[_EqOrderType] = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
280 on_setattr: Optional[_OnSetAttrArgType] = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
281 ) -> _T: ...
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
282
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
283 # This form covers type=non-Type: e.g. forward references (str), Any
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
284 @overload
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
285 def field(
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
286 *,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
287 default: Optional[_T] = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
288 validator: Optional[_ValidatorArgType[_T]] = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
289 repr: _ReprArgType = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
290 hash: Optional[bool] = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
291 init: bool = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
292 metadata: Optional[Mapping[Any, Any]] = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
293 converter: Optional[_ConverterType] = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
294 factory: Optional[Callable[[], _T]] = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
295 kw_only: bool = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
296 eq: Optional[_EqOrderType] = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
297 order: Optional[_EqOrderType] = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
298 on_setattr: Optional[_OnSetAttrArgType] = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
299 ) -> Any: ...
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
300 @overload
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
301 @__dataclass_transform__(order_default=True, field_descriptors=(attrib, field))
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
302 def attrs(
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
303 maybe_cls: _C,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
304 these: Optional[Dict[str, Any]] = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
305 repr_ns: Optional[str] = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
306 repr: bool = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
307 cmp: Optional[_EqOrderType] = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
308 hash: Optional[bool] = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
309 init: bool = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
310 slots: bool = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
311 frozen: bool = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
312 weakref_slot: bool = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
313 str: bool = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
314 auto_attribs: bool = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
315 kw_only: bool = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
316 cache_hash: bool = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
317 auto_exc: bool = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
318 eq: Optional[_EqOrderType] = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
319 order: Optional[_EqOrderType] = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
320 auto_detect: bool = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
321 collect_by_mro: bool = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
322 getstate_setstate: Optional[bool] = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
323 on_setattr: Optional[_OnSetAttrArgType] = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
324 field_transformer: Optional[_FieldTransformer] = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
325 match_args: bool = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
326 ) -> _C: ...
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
327 @overload
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
328 @__dataclass_transform__(order_default=True, field_descriptors=(attrib, field))
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
329 def attrs(
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
330 maybe_cls: None = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
331 these: Optional[Dict[str, Any]] = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
332 repr_ns: Optional[str] = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
333 repr: bool = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
334 cmp: Optional[_EqOrderType] = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
335 hash: Optional[bool] = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
336 init: bool = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
337 slots: bool = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
338 frozen: bool = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
339 weakref_slot: bool = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
340 str: bool = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
341 auto_attribs: bool = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
342 kw_only: bool = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
343 cache_hash: bool = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
344 auto_exc: bool = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
345 eq: Optional[_EqOrderType] = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
346 order: Optional[_EqOrderType] = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
347 auto_detect: bool = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
348 collect_by_mro: bool = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
349 getstate_setstate: Optional[bool] = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
350 on_setattr: Optional[_OnSetAttrArgType] = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
351 field_transformer: Optional[_FieldTransformer] = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
352 match_args: bool = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
353 ) -> Callable[[_C], _C]: ...
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
354 @overload
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
355 @__dataclass_transform__(field_descriptors=(attrib, field))
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
356 def define(
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
357 maybe_cls: _C,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
358 *,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
359 these: Optional[Dict[str, Any]] = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
360 repr: bool = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
361 hash: Optional[bool] = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
362 init: bool = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
363 slots: bool = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
364 frozen: bool = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
365 weakref_slot: bool = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
366 str: bool = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
367 auto_attribs: bool = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
368 kw_only: bool = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
369 cache_hash: bool = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
370 auto_exc: bool = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
371 eq: Optional[bool] = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
372 order: Optional[bool] = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
373 auto_detect: bool = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
374 getstate_setstate: Optional[bool] = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
375 on_setattr: Optional[_OnSetAttrArgType] = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
376 field_transformer: Optional[_FieldTransformer] = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
377 match_args: bool = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
378 ) -> _C: ...
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
379 @overload
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
380 @__dataclass_transform__(field_descriptors=(attrib, field))
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
381 def define(
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
382 maybe_cls: None = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
383 *,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
384 these: Optional[Dict[str, Any]] = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
385 repr: bool = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
386 hash: Optional[bool] = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
387 init: bool = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
388 slots: bool = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
389 frozen: bool = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
390 weakref_slot: bool = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
391 str: bool = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
392 auto_attribs: bool = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
393 kw_only: bool = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
394 cache_hash: bool = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
395 auto_exc: bool = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
396 eq: Optional[bool] = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
397 order: Optional[bool] = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
398 auto_detect: bool = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
399 getstate_setstate: Optional[bool] = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
400 on_setattr: Optional[_OnSetAttrArgType] = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
401 field_transformer: Optional[_FieldTransformer] = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
402 match_args: bool = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
403 ) -> Callable[[_C], _C]: ...
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
404
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
405 mutable = define
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
406 frozen = define # they differ only in their defaults
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
407
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
408 def fields(cls: Type[AttrsInstance]) -> Any: ...
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
409 def fields_dict(cls: Type[AttrsInstance]) -> Dict[str, Attribute[Any]]: ...
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
410 def validate(inst: AttrsInstance) -> None: ...
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
411 def resolve_types(
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
412 cls: _C,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
413 globalns: Optional[Dict[str, Any]] = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
414 localns: Optional[Dict[str, Any]] = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
415 attribs: Optional[List[Attribute[Any]]] = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
416 ) -> _C: ...
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
417
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
418 # TODO: add support for returning a proper attrs class from the mypy plugin
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
419 # we use Any instead of _CountingAttr so that e.g. `make_class('Foo',
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
420 # [attr.ib()])` is valid
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
421 def make_class(
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
422 name: str,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
423 attrs: Union[List[str], Tuple[str, ...], Dict[str, Any]],
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
424 bases: Tuple[type, ...] = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
425 repr_ns: Optional[str] = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
426 repr: bool = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
427 cmp: Optional[_EqOrderType] = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
428 hash: Optional[bool] = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
429 init: bool = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
430 slots: bool = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
431 frozen: bool = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
432 weakref_slot: bool = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
433 str: bool = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
434 auto_attribs: bool = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
435 kw_only: bool = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
436 cache_hash: bool = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
437 auto_exc: bool = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
438 eq: Optional[_EqOrderType] = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
439 order: Optional[_EqOrderType] = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
440 collect_by_mro: bool = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
441 on_setattr: Optional[_OnSetAttrArgType] = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
442 field_transformer: Optional[_FieldTransformer] = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
443 ) -> type: ...
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
444
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
445 # _funcs --
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
446
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
447 # TODO: add support for returning TypedDict from the mypy plugin
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
448 # FIXME: asdict/astuple do not honor their factory args. Waiting on one of
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
449 # these:
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
450 # https://github.com/python/mypy/issues/4236
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
451 # https://github.com/python/typing/issues/253
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
452 # XXX: remember to fix attrs.asdict/astuple too!
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
453 def asdict(
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
454 inst: AttrsInstance,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
455 recurse: bool = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
456 filter: Optional[_FilterType[Any]] = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
457 dict_factory: Type[Mapping[Any, Any]] = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
458 retain_collection_types: bool = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
459 value_serializer: Optional[
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
460 Callable[[type, Attribute[Any], Any], Any]
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
461 ] = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
462 tuple_keys: Optional[bool] = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
463 ) -> Dict[str, Any]: ...
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
464
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
465 # TODO: add support for returning NamedTuple from the mypy plugin
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
466 def astuple(
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
467 inst: AttrsInstance,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
468 recurse: bool = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
469 filter: Optional[_FilterType[Any]] = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
470 tuple_factory: Type[Sequence[Any]] = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
471 retain_collection_types: bool = ...,
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
472 ) -> Tuple[Any, ...]: ...
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
473 def has(cls: type) -> bool: ...
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
474 def assoc(inst: _T, **changes: Any) -> _T: ...
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
475 def evolve(inst: _T, **changes: Any) -> _T: ...
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
476
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
477 # _config --
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
478
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
479 def set_run_validators(run: bool) -> None: ...
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
480 def get_run_validators() -> bool: ...
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
481
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
482 # aliases --
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
483
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
484 s = attributes = attrs
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
485 ib = attr = attrib
e1c586b9a43c attr: vendor 22.1.0
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
486 dataclass = attrs # Technically, partial(attrs, auto_attribs=True) ;)