@@ -587,7 +587,7 @@ def __init__( # noqa: C901
587
587
if archflags is not None :
588
588
arch , * other = filter (None , (x .strip () for x in archflags .split ('-arch' )))
589
589
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} ' )
591
591
macver , _ , nativearch = platform .mac_ver ()
592
592
if arch != nativearch :
593
593
x = self ._env .setdefault ('_PYTHON_HOST_PLATFORM' , f'macosx-{ macver } -{ arch } ' )
@@ -676,10 +676,7 @@ def _get_config_key(self, key: str) -> Any:
676
676
value : Any = self ._config
677
677
for part in f'tool.meson-python.{ key } ' .split ('.' ):
678
678
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 )} ' )
683
680
value = value .get (part , {})
684
681
return value
685
682
@@ -734,29 +731,28 @@ def _validate_metadata(self) -> None:
734
731
if key not in self ._ALLOWED_DYNAMIC_FIELDS
735
732
}
736
733
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 } ' )
740
736
741
737
# check if we are running on an unsupported interpreter
742
738
if self ._metadata .requires_python :
743
739
self ._metadata .requires_python .prereleases = True
744
740
if platform .python_version ().rstrip ('+' ) not in self ._metadata .requires_python :
745
741
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 } '
748
744
)
749
745
750
746
def _check_for_unknown_config_keys (self , valid_args : Mapping [str , Collection [str ]]) -> None :
751
747
config = self ._config .get ('tool' , {}).get ('meson-python' , {})
752
748
753
749
for key , valid_subkeys in config .items ():
754
750
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 } " ' )
756
752
757
753
for subkey in valid_args [key ]:
758
754
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 } " ' )
760
756
761
757
@cached_property
762
758
def _wheel_builder (self ) -> _WheelBuilder :
@@ -978,10 +974,10 @@ def _project(config_settings: Optional[Dict[Any, Any]]) -> Iterator[Project]:
978
974
builddir_value = config_settings .get ('builddir' , {})
979
975
if len (builddir_value ) > 0 :
980
976
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 ' )
982
978
builddir = builddir_value [0 ]
983
979
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 )} ' )
985
981
else :
986
982
builddir = None
987
983
@@ -992,14 +988,8 @@ def _validate_string_collection(key: str) -> None:
992
988
for item in config_settings .get (key , ())
993
989
)))
994
990
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 } ' )
1003
993
1004
994
meson_args_keys = typing_get_args (MesonArgsKeys )
1005
995
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:
1010
1000
import difflib
1011
1001
matches = difflib .get_close_matches (key , known_keys , n = 3 )
1012
1002
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 } ?' )
1014
1005
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 } "' )
1017
1007
1018
1008
for key in meson_args_cli_keys :
1019
1009
_validate_string_collection (key )
0 commit comments