11from _typeshed import Unused
22from collections .abc import Callable , Iterable
33from ipaddress import IPv4Interface , IPv4Network , IPv6Interface , IPv6Network
4- from typing import Literal , TypeVar , overload
4+ from typing import Literal , overload
55
66from django .db .models .expressions import Combinable
77from django .db .models .fields import Field , _ErrorMessagesToOverride , _ValidatorCallable
@@ -11,9 +11,8 @@ from netfields.forms import CidrAddressFormField, InetAddressFormField, NoPrefix
1111
1212NET_OPERATORS : dict [str , str ]
1313NET_TEXT_OPERATORS : list [str ]
14- _I = TypeVar ("_I" , bound = IPv4Interface | IPv6Interface | None )
1514
16- class InetAddressField (Field [_I | Combinable , _I ]):
15+ class InetAddressField [ I : IPv4Interface | IPv6Interface | None ] (Field [I | Combinable , I ]):
1716 @overload
1817 def __new__ (
1918 cls ,
@@ -25,14 +24,14 @@ class InetAddressField(Field[_I | Combinable, _I]):
2524 blank : bool = False ,
2625 null : Literal [False ] = False ,
2726 db_index : bool = False ,
28- default : _I | Callable [[], _I ] | None = ...,
27+ default : I | Callable [[], I ] | None = ...,
2928 editable : bool = True ,
3029 auto_created : bool = False ,
3130 serialize : bool = True ,
3231 unique_for_date : str | None = None ,
3332 unique_for_month : str | None = None ,
3433 unique_for_year : str | None = None ,
35- choices : Iterable [tuple [_I , str ] | tuple [str , Iterable [tuple [_I , str ]]]] | None = None ,
34+ choices : Iterable [tuple [I , str ] | tuple [str , Iterable [tuple [I , str ]]]] | None = None ,
3635 help_text : str = "" ,
3736 db_column : str | None = None ,
3837 db_tablespace : str | None = None ,
@@ -52,14 +51,14 @@ class InetAddressField(Field[_I | Combinable, _I]):
5251 * ,
5352 null : Literal [True ],
5453 db_index : bool = False ,
55- default : _I | Callable [[], _I ] = ...,
54+ default : I | Callable [[], I ] = ...,
5655 editable : bool = True ,
5756 auto_created : bool = False ,
5857 serialize : bool = True ,
5958 unique_for_date : str | None = None ,
6059 unique_for_month : str | None = None ,
6160 unique_for_year : str | None = None ,
62- choices : Iterable [tuple [_I , str ] | tuple [str , Iterable [tuple [_I , str ]]]] | None = None ,
61+ choices : Iterable [tuple [I , str ] | tuple [str , Iterable [tuple [I , str ]]]] | None = None ,
6362 help_text : str = "" ,
6463 db_column : str | None = None ,
6564 db_tablespace : str | None = None ,
@@ -70,9 +69,7 @@ class InetAddressField(Field[_I | Combinable, _I]):
7069 def python_type (self ) -> Callable [..., IPv4Interface | IPv6Interface ]: ...
7170 def form_class (self ) -> type [InetAddressFormField | NoPrefixInetAddressFormField ]: ...
7271
73- _N = TypeVar ("_N" , bound = IPv4Network | IPv6Network | None )
74-
75- class CidrAddressField (Field [_N | Combinable , _N ]):
72+ class CidrAddressField [N : IPv4Network | IPv6Network | None ](Field [N | Combinable , N ]):
7673 @overload
7774 def __new__ (
7875 cls ,
@@ -84,14 +81,14 @@ class CidrAddressField(Field[_N | Combinable, _N]):
8481 blank : bool = False ,
8582 null : Literal [False ] = False ,
8683 db_index : bool = False ,
87- default : _N | Callable [[], _N ] | None = ...,
84+ default : N | Callable [[], N ] | None = ...,
8885 editable : bool = True ,
8986 auto_created : bool = False ,
9087 serialize : bool = True ,
9188 unique_for_date : str | None = None ,
9289 unique_for_month : str | None = None ,
9390 unique_for_year : str | None = None ,
94- choices : Iterable [tuple [_N , str ] | tuple [str , Iterable [tuple [_N , str ]]]] | None = None ,
91+ choices : Iterable [tuple [N , str ] | tuple [str , Iterable [tuple [N , str ]]]] | None = None ,
9592 help_text : str = "" ,
9693 db_column : str | None = None ,
9794 db_tablespace : str | None = None ,
@@ -110,14 +107,14 @@ class CidrAddressField(Field[_N | Combinable, _N]):
110107 * ,
111108 null : Literal [True ],
112109 db_index : bool = False ,
113- default : _N | Callable [[], _N ] = ...,
110+ default : N | Callable [[], N ] = ...,
114111 editable : bool = True ,
115112 auto_created : bool = False ,
116113 serialize : bool = True ,
117114 unique_for_date : str | None = None ,
118115 unique_for_month : str | None = None ,
119116 unique_for_year : str | None = None ,
120- choices : Iterable [tuple [_N , str ] | tuple [str , Iterable [tuple [_N , str ]]]] | None = None ,
117+ choices : Iterable [tuple [N , str ] | tuple [str , Iterable [tuple [N , str ]]]] | None = None ,
121118 help_text : str = "" ,
122119 db_column : str | None = None ,
123120 db_tablespace : str | None = None ,
@@ -127,9 +124,7 @@ class CidrAddressField(Field[_N | Combinable, _N]):
127124 def python_type (self ) -> Callable [..., IPv4Network | IPv6Network ]: ...
128125 def form_class (self ) -> type [CidrAddressFormField ]: ...
129126
130- _E = TypeVar ("_E" , bound = EUI | None )
131-
132- class MACAddressField (Field [_E | Combinable , _E ]):
127+ class MACAddressField [E : EUI | None ](Field [E | Combinable , E ]):
133128 @overload
134129 def __new__ (
135130 cls ,
@@ -141,14 +136,14 @@ class MACAddressField(Field[_E | Combinable, _E]):
141136 blank : bool = False ,
142137 null : Literal [False ] = False ,
143138 db_index : bool = False ,
144- default : _E | Callable [[], _E ] | None = ...,
139+ default : E | Callable [[], E ] | None = ...,
145140 editable : bool = True ,
146141 auto_created : bool = False ,
147142 serialize : bool = True ,
148143 unique_for_date : str | None = None ,
149144 unique_for_month : str | None = None ,
150145 unique_for_year : str | None = None ,
151- choices : Iterable [tuple [_E , str ] | tuple [str , Iterable [tuple [_E , str ]]]] | None = None ,
146+ choices : Iterable [tuple [E , str ] | tuple [str , Iterable [tuple [E , str ]]]] | None = None ,
152147 help_text : str = "" ,
153148 db_column : str | None = None ,
154149 db_tablespace : str | None = None ,
@@ -167,14 +162,14 @@ class MACAddressField(Field[_E | Combinable, _E]):
167162 * ,
168163 null : Literal [True ],
169164 db_index : bool = False ,
170- default : _E | Callable [[], _E ] = ...,
165+ default : E | Callable [[], E ] = ...,
171166 editable : bool = True ,
172167 auto_created : bool = False ,
173168 serialize : bool = True ,
174169 unique_for_date : str | None = None ,
175170 unique_for_month : str | None = None ,
176171 unique_for_year : str | None = None ,
177- choices : Iterable [tuple [_E , str ] | tuple [str , Iterable [tuple [_E , str ]]]] | None = None ,
172+ choices : Iterable [tuple [E , str ] | tuple [str , Iterable [tuple [E , str ]]]] | None = None ,
178173 help_text : str = "" ,
179174 db_column : str | None = None ,
180175 db_tablespace : str | None = None ,
@@ -184,7 +179,7 @@ class MACAddressField(Field[_E | Combinable, _E]):
184179 def from_db_value (self , value : str , expression : Unused , connection : Unused , * args : Unused ) -> EUI | None : ...
185180 def get_db_prep_value (self , value : int | str | EUI | None , connection : Unused , prepared : bool = False ) -> str : ...
186181
187- class MACAddress8Field (Field [_E | Combinable , _E ]):
182+ class MACAddress8Field [ E : EUI | None ] (Field [E | Combinable , E ]):
188183 @overload
189184 def __new__ (
190185 cls ,
@@ -196,14 +191,14 @@ class MACAddress8Field(Field[_E | Combinable, _E]):
196191 blank : bool = False ,
197192 null : Literal [False ] = False ,
198193 db_index : bool = False ,
199- default : _E | Callable [[], _E ] | None = ...,
194+ default : E | Callable [[], E ] | None = ...,
200195 editable : bool = True ,
201196 auto_created : bool = False ,
202197 serialize : bool = True ,
203198 unique_for_date : str | None = None ,
204199 unique_for_month : str | None = None ,
205200 unique_for_year : str | None = None ,
206- choices : Iterable [tuple [_E , str ] | tuple [str , Iterable [tuple [_E , str ]]]] | None = None ,
201+ choices : Iterable [tuple [E , str ] | tuple [str , Iterable [tuple [E , str ]]]] | None = None ,
207202 help_text : str = "" ,
208203 db_column : str | None = None ,
209204 db_tablespace : str | None = None ,
@@ -222,14 +217,14 @@ class MACAddress8Field(Field[_E | Combinable, _E]):
222217 * ,
223218 null : Literal [True ],
224219 db_index : bool = False ,
225- default : _E | Callable [[], _E ] = ...,
220+ default : E | Callable [[], E ] = ...,
226221 editable : bool = True ,
227222 auto_created : bool = False ,
228223 serialize : bool = True ,
229224 unique_for_date : str | None = None ,
230225 unique_for_month : str | None = None ,
231226 unique_for_year : str | None = None ,
232- choices : Iterable [tuple [_E , str ] | tuple [str , Iterable [tuple [_E , str ]]]] | None = None ,
227+ choices : Iterable [tuple [E , str ] | tuple [str , Iterable [tuple [E , str ]]]] | None = None ,
233228 help_text : str = "" ,
234229 db_column : str | None = None ,
235230 db_tablespace : str | None = None ,
0 commit comments