@@ -587,7 +587,7 @@ def __init__( # noqa: C901
587587 if archflags is not None :
588588 arch , * other = filter (None , (x .strip () for x in archflags .split ('-arch' )))
589589 if other :
590- raise ConfigError (f'multi -architecture builds are not supported but $ARCHFLAGS={ archflags !r} ' )
590+ raise ConfigError (f'Multi -architecture builds are not supported but $ARCHFLAGS={ archflags !r} ' )
591591 macver , _ , nativearch = platform .mac_ver ()
592592 if arch != nativearch :
593593 x = self ._env .setdefault ('_PYTHON_HOST_PLATFORM' , f'macosx-{ macver } -{ arch } ' )
@@ -676,10 +676,7 @@ def _get_config_key(self, key: str) -> Any:
676676 value : Any = self ._config
677677 for part in f'tool.meson-python.{ key } ' .split ('.' ):
678678 if not isinstance (value , Mapping ):
679- raise ConfigError (
680- f'Found unexpected value in `{ part } ` when looking for '
681- f'config key `tool.meson-python.{ key } ` (`{ value } `)'
682- )
679+ raise ConfigError (f'Configuration entry "tool.meson-python.{ key } " should be a TOML table not { type (value )} ' )
683680 value = value .get (part , {})
684681 return value
685682
@@ -734,29 +731,28 @@ def _validate_metadata(self) -> None:
734731 if key not in self ._ALLOWED_DYNAMIC_FIELDS
735732 }
736733 if unsupported_dynamic :
737- raise MesonBuilderError ('Unsupported dynamic fields: {}' .format (
738- ', ' .join (unsupported_dynamic )),
739- )
734+ s = ', ' .join (f'"{ x } "' for x in unsupported_dynamic )
735+ raise MesonBuilderError (f'Unsupported dynamic fields: { s } ' )
740736
741737 # check if we are running on an unsupported interpreter
742738 if self ._metadata .requires_python :
743739 self ._metadata .requires_python .prereleases = True
744740 if platform .python_version ().rstrip ('+' ) not in self ._metadata .requires_python :
745741 raise MesonBuilderError (
746- f'Unsupported Python version ` { platform .python_version ()} ` , '
747- f'expected ` { self ._metadata .requires_python } ` '
742+ f'Unsupported Python version { platform .python_version ()} , '
743+ f'expected { self ._metadata .requires_python } '
748744 )
749745
750746 def _check_for_unknown_config_keys (self , valid_args : Mapping [str , Collection [str ]]) -> None :
751747 config = self ._config .get ('tool' , {}).get ('meson-python' , {})
752748
753749 for key , valid_subkeys in config .items ():
754750 if key not in valid_args :
755- raise ConfigError (f'Unknown configuration key: tool.meson-python.{ key } ' )
751+ raise ConfigError (f'Unknown configuration key " tool.meson-python.{ key } " ' )
756752
757753 for subkey in valid_args [key ]:
758754 if subkey not in valid_subkeys :
759- raise ConfigError (f'Unknown configuration key: tool.meson-python.{ key } .{ subkey } ' )
755+ raise ConfigError (f'Unknown configuration key " tool.meson-python.{ key } .{ subkey } " ' )
760756
761757 @cached_property
762758 def _wheel_builder (self ) -> _WheelBuilder :
@@ -978,10 +974,10 @@ def _project(config_settings: Optional[Dict[Any, Any]]) -> Iterator[Project]:
978974 builddir_value = config_settings .get ('builddir' , {})
979975 if len (builddir_value ) > 0 :
980976 if len (builddir_value ) != 1 :
981- raise ConfigError ('Specified multiple values for `builddir`, only one is allowed ' )
977+ raise ConfigError ('Only one value for configuration entry "builddir" can be specified ' )
982978 builddir = builddir_value [0 ]
983979 if not isinstance (builddir , str ):
984- raise ConfigError (f'Config option ` builddir` should be a string (found ` { type (builddir )} `) ' )
980+ raise ConfigError (f'Configuration entry " builddir" should be a string not { type (builddir )} ' )
985981 else :
986982 builddir = None
987983
@@ -992,14 +988,8 @@ def _validate_string_collection(key: str) -> None:
992988 for item in config_settings .get (key , ())
993989 )))
994990 if problematic_items :
995- raise ConfigError (
996- f'Config option `{ key } ` should only contain string items, but '
997- 'contains the following parameters that do not meet this criteria:' +
998- '' .join ((
999- f'\t - { item } (type: { type (item )} )'
1000- for item in problematic_items
1001- ))
1002- )
991+ s = ', ' .join (f'"{ item } " ({ type (item )} )' for item in problematic_items )
992+ raise ConfigError (f'Configuration entries for "{ key } " must be strings but contain: { s } ' )
1003993
1004994 meson_args_keys = typing_get_args (MesonArgsKeys )
1005995 meson_args_cli_keys = tuple (f'{ key } -args' for key in meson_args_keys )
@@ -1010,10 +1000,10 @@ def _validate_string_collection(key: str) -> None:
10101000 import difflib
10111001 matches = difflib .get_close_matches (key , known_keys , n = 3 )
10121002 if len (matches ):
1013- postfix = f'Did you mean one of: { matches } '
1003+ alternatives = ' or ' .join (f'"{ match } "' for match in matches )
1004+ raise ConfigError (f'Unknown configuration entry "{ key } ". Did you mean { alternatives } ?' )
10141005 else :
1015- postfix = 'There are no close valid keys.'
1016- raise ConfigError (f'Unknown config setting: { key !r} . { postfix } ' )
1006+ raise ConfigError (f'Unknown configuration entry "{ key } "' )
10171007
10181008 for key in meson_args_cli_keys :
10191009 _validate_string_collection (key )
0 commit comments