@@ -310,7 +310,7 @@ def is_for_build(self) -> bool:
310310 return self .machine is MachineChoice .BUILD
311311
312312if T .TYPE_CHECKING :
313- OptionDict : TypeAlias = T .Dict [T . Union [ OptionKey , str ] , ElementaryOptionValues ]
313+ OptionDict : TypeAlias = T .Dict [OptionKey , ElementaryOptionValues ]
314314
315315@dataclasses .dataclass
316316class UserOption (T .Generic [_T ], HoldableObject ):
@@ -809,13 +809,13 @@ def __init__(self, is_cross: bool) -> None:
809809 self .module_options : T .Set [OptionKey ] = set ()
810810 from .compilers import all_languages
811811 self .all_languages = set (all_languages )
812- self .augments : T . Dict [ OptionKey , ElementaryOptionValues ] = {}
812+ self .augments : OptionDict = {}
813813 self .is_cross = is_cross
814814
815815 # Pending options are options that need to be initialized later, either
816816 # configuration dependent options like compiler options, or options for
817817 # a different subproject
818- self .pending_options : T . Dict [ OptionKey , ElementaryOptionValues ] = {}
818+ self .pending_options : OptionDict = {}
819819
820820 def clear_pending (self ) -> None :
821821 self .pending_options = {}
@@ -1248,7 +1248,7 @@ def prefix_split_options(self, coll: OptionDict) -> T.Tuple[T.Optional[str], Opt
12481248 prefix = None
12491249 others_d : OptionDict = {}
12501250 for k , v in coll .items ():
1251- if k == 'prefix' or ( isinstance ( k , OptionKey ) and k .name == 'prefix' ) :
1251+ if k .name == 'prefix' :
12521252 if not isinstance (v , str ):
12531253 raise MesonException ('Incorrect type for prefix option (expected string)' )
12541254 prefix = v
@@ -1259,13 +1259,10 @@ def prefix_split_options(self, coll: OptionDict) -> T.Tuple[T.Optional[str], Opt
12591259 def first_handle_prefix (self ,
12601260 project_default_options : OptionDict ,
12611261 cmd_line_options : OptionDict ,
1262- machine_file_options : T .Mapping [OptionKey , ElementaryOptionValues ]) \
1263- -> T .Tuple [OptionDict ,
1264- OptionDict ,
1265- T .MutableMapping [OptionKey , ElementaryOptionValues ]]:
1262+ machine_file_options : OptionDict ) \
1263+ -> T .Tuple [OptionDict , OptionDict , OptionDict ]:
12661264 # Copy to avoid later mutation
1267- nopref_machine_file_options = T .cast (
1268- 'T.MutableMapping[OptionKey, ElementaryOptionValues]' , copy .copy (machine_file_options ))
1265+ nopref_machine_file_options = copy .copy (machine_file_options )
12691266
12701267 prefix = None
12711268 (possible_prefix , nopref_project_default_options ) = self .prefix_split_options (project_default_options )
@@ -1298,15 +1295,11 @@ def hard_reset_from_prefix(self, prefix: str) -> None:
12981295 def initialize_from_top_level_project_call (self ,
12991296 project_default_options_in : OptionDict ,
13001297 cmd_line_options_in : OptionDict ,
1301- machine_file_options_in : T . Mapping [ OptionKey , ElementaryOptionValues ] ) -> None :
1298+ machine_file_options_in : OptionDict ) -> None :
13021299 (project_default_options , cmd_line_options , machine_file_options ) = self .first_handle_prefix (project_default_options_in ,
13031300 cmd_line_options_in ,
13041301 machine_file_options_in )
1305- for keystr , valstr in project_default_options .items ():
1306- if isinstance (keystr , str ):
1307- key = OptionKey .from_string (keystr )
1308- else :
1309- key = keystr
1302+ for key , valstr in project_default_options .items ():
13101303 # Due to backwards compatibility we ignore build-machine options
13111304 # when building natively.
13121305 if not self .is_cross and key .is_for_build ():
@@ -1328,11 +1321,7 @@ def initialize_from_top_level_project_call(self,
13281321 self .augments [key ] = valstr
13291322 else :
13301323 self .set_option_maybe_root (key , valstr , True )
1331- for keystr , valstr in cmd_line_options .items ():
1332- if isinstance (keystr , str ):
1333- key = OptionKey .from_string (keystr )
1334- else :
1335- key = keystr
1324+ for key , valstr in cmd_line_options .items ():
13361325 # Due to backwards compatibility we ignore all build-machine options
13371326 # when building natively.
13381327 if not self .is_cross and key .is_for_build ():
@@ -1361,12 +1350,7 @@ def accept_as_pending_option(self, key: OptionKey, known_subprojects: T.Optional
13611350
13621351 def validate_cmd_line_options (self , cmd_line_options : OptionDict ) -> None :
13631352 unknown_options = []
1364- for keystr , valstr in cmd_line_options .items ():
1365- if isinstance (keystr , str ):
1366- key = OptionKey .from_string (keystr )
1367- else :
1368- key = keystr
1369-
1353+ for key , valstr in cmd_line_options .items ():
13701354 if key in self .pending_options and not self .accept_as_pending_option (key ):
13711355 unknown_options .append (f'"{ key } "' )
13721356
@@ -1379,11 +1363,7 @@ def initialize_from_subproject_call(self,
13791363 spcall_default_options : OptionDict ,
13801364 project_default_options : OptionDict ,
13811365 cmd_line_options : OptionDict ) -> None :
1382- for keystr , valstr in itertools .chain (project_default_options .items (), spcall_default_options .items ()):
1383- if isinstance (keystr , str ):
1384- key = OptionKey .from_string (keystr )
1385- else :
1386- key = keystr
1366+ for key , valstr in itertools .chain (project_default_options .items (), spcall_default_options .items ()):
13871367 if key .subproject is None :
13881368 key = key .evolve (subproject = subproject )
13891369 elif key .subproject == subproject :
@@ -1397,9 +1377,7 @@ def initialize_from_subproject_call(self,
13971377 self .pending_options .pop (key , None )
13981378 self .augments [key ] = valstr
13991379 # Check for pending options
1400- for key , valstr in cmd_line_options .items (): # type: ignore [assignment]
1401- if not isinstance (key , OptionKey ):
1402- key = OptionKey .from_string (key )
1380+ for key , valstr in cmd_line_options .items ():
14031381 if key .subproject != subproject :
14041382 continue
14051383 self .pending_options .pop (key , None )
0 commit comments