@@ -13,6 +13,8 @@ from typing import (
1313from django .db .models import Field , IntegerChoices , TextChoices
1414from typing_extensions import TypeAlias
1515
16+ from django_choices_field .types import IntegerChoicesFlag
17+
1618_ValidatorCallable : TypeAlias = Callable [..., None ]
1719_ErrorMessagesToOverride : TypeAlias = Dict [str , Any ]
1820
@@ -145,3 +147,68 @@ class IntegerChoicesField(Generic[_I], Field[_I, _I]):
145147 allow_files : bool = ...,
146148 allow_folders : bool = ...,
147149 ) -> IntegerChoicesField [_I | None ]: ...
150+
151+ _IF = TypeVar ("_IF" , bound = Optional [IntegerChoicesFlag ])
152+
153+ class IntegerChoicesFlagField (Generic [_IF ], Field [_IF , _IF ]):
154+ choices_enum : type [_IF ]
155+ @overload
156+ def __new__ (
157+ cls ,
158+ choices_enum : type [_IF ],
159+ verbose_name : str | None = ...,
160+ name : str | None = ...,
161+ primary_key : bool = ...,
162+ max_length : int | None = ...,
163+ unique : bool = ...,
164+ blank : bool = ...,
165+ null : Literal [False ] = ...,
166+ db_index : bool = ...,
167+ default : _IF | Callable [[], _IF ] = ...,
168+ editable : bool = ...,
169+ auto_created : bool = ...,
170+ serialize : bool = ...,
171+ unique_for_date : str | None = ...,
172+ unique_for_month : str | None = ...,
173+ unique_for_year : str | None = ...,
174+ help_text : str = ...,
175+ db_column : str | None = ...,
176+ db_tablespace : str | None = ...,
177+ validators : Iterable [_ValidatorCallable ] = ...,
178+ error_messages : _ErrorMessagesToOverride | None = ...,
179+ path : str | Callable [..., str ] = ...,
180+ match : str | None = ...,
181+ recursive : bool = ...,
182+ allow_files : bool = ...,
183+ allow_folders : bool = ...,
184+ ) -> IntegerChoicesFlagField [_IF ]: ...
185+ @overload
186+ def __new__ (
187+ cls ,
188+ choices_enum : type [_IF ],
189+ verbose_name : str | None = ...,
190+ name : str | None = ...,
191+ primary_key : bool = ...,
192+ max_length : int | None = ...,
193+ unique : bool = ...,
194+ blank : bool = ...,
195+ null : Literal [True ] = ...,
196+ db_index : bool = ...,
197+ default : _IF | Callable [[], _IF ] | None = ...,
198+ editable : bool = ...,
199+ auto_created : bool = ...,
200+ serialize : bool = ...,
201+ unique_for_date : str | None = ...,
202+ unique_for_month : str | None = ...,
203+ unique_for_year : str | None = ...,
204+ help_text : str = ...,
205+ db_column : str | None = ...,
206+ db_tablespace : str | None = ...,
207+ validators : Iterable [_ValidatorCallable ] = ...,
208+ error_messages : _ErrorMessagesToOverride | None = ...,
209+ path : str | Callable [..., str ] = ...,
210+ match : str | None = ...,
211+ recursive : bool = ...,
212+ allow_files : bool = ...,
213+ allow_folders : bool = ...,
214+ ) -> IntegerChoicesFlagField [_IF | None ]: ...
0 commit comments