File tree Expand file tree Collapse file tree 5 files changed +17
-12
lines changed
Expand file tree Collapse file tree 5 files changed +17
-12
lines changed Original file line number Diff line number Diff line change 88 AdminViewset ,
99 register_viewset ,
1010)
11+ from plain .models import QuerySet
1112from plain .models .forms import ModelForm
13+ from plain .preflight import PreflightResult
1214
1315from .models import Flag , FlagResult
1416
@@ -17,13 +19,13 @@ class UnusedFlagsCard(Card):
1719 title = "Unused Flags"
1820
1921 @cached_property
20- def flag_errors (self ):
22+ def flag_errors (self ) -> list [ PreflightResult ] :
2123 return Flag .preflight ()
2224
23- def get_number (self ):
25+ def get_number (self ) -> int :
2426 return len (self .flag_errors )
2527
26- def get_text (self ):
28+ def get_text (self ) -> str :
2729 return "\n " .join (str (e .fix ) for e in self .flag_errors )
2830
2931
@@ -63,7 +65,7 @@ class ListView(AdminModelListView):
6365 nav_section = "Feature flags"
6466 nav_icon = "flag"
6567
66- def get_initial_queryset (self ):
68+ def get_initial_queryset (self ) -> QuerySet :
6769 return self .model .query .all ().select_related ("flag" )
6870
6971 class DetailView (AdminModelDetailView ):
Original file line number Diff line number Diff line change 1+ from types import ModuleType
2+
13from plain .runtime import settings
24
35from . import exceptions
46from .flags import Flag
57
68
7- def get_flags_module ():
9+ def get_flags_module () -> ModuleType :
810 flags_module = settings .FLAGS_MODULE
911
1012 try :
Original file line number Diff line number Diff line change @@ -95,7 +95,7 @@ def retrieve_or_compute_value(self) -> Any:
9595
9696 span .set_attribute (
9797 FEATURE_FLAG_RESULT_REASON ,
98- FeatureFlagResultReasonValues .DYNAMIC .value ,
98+ FeatureFlagResultReasonValues .TARGETING_MATCH .value ,
9999 )
100100 span .set_attribute (FEATURE_FLAG_RESULT_VALUE , str (value ))
101101
@@ -142,13 +142,13 @@ def __bool__(self) -> bool:
142142 """
143143 return bool (self .value )
144144
145- def __contains__ (self , item ) -> bool :
145+ def __contains__ (self , item : Any ) -> bool :
146146 """
147147 Allow for use in `in` expressions.
148148 """
149149 return item in self .value
150150
151- def __eq__ (self , other ) -> bool :
151+ def __eq__ (self , other : object ) -> bool :
152152 """
153153 Allow for use in `==` expressions.
154154 """
Original file line number Diff line number Diff line change 1010from .exceptions import FlagImportError
1111
1212
13- def validate_flag_name (value ) :
13+ def validate_flag_name (value : str ) -> None :
1414 if not re .match (r"^[a-zA-Z_][a-zA-Z0-9_]*$" , value ):
1515 raise ValidationError (f"{ value } is not a valid Python identifier name" )
1616
@@ -30,7 +30,7 @@ class Meta:
3030 ),
3131 ]
3232
33- def __str__ (self ):
33+ def __str__ (self ) -> str :
3434 return self .key
3535
3636
@@ -57,11 +57,11 @@ class Meta:
5757 ),
5858 ]
5959
60- def __str__ (self ):
60+ def __str__ (self ) -> str :
6161 return self .name
6262
6363 @classmethod
64- def preflight (cls ):
64+ def preflight (cls ) -> list [ PreflightResult ] :
6565 """
6666 Check for flags that are in the database, but no longer defined in code.
6767
Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ FULLY_TYPED_DIRS = [
2323 "plain-elements/plain/elements" ,
2424 "plain-email/plain/email" ,
2525 "plain-esbuild/plain/esbuild" ,
26+ "plain-flags/plain/flags" ,
2627 "plain-sessions/plain/sessions" ,
2728]
2829
You can’t perform that action at this time.
0 commit comments