@@ -78,6 +78,7 @@ def canonicalize_license_expression(s: str) -> str:
7878
7979__version__ = '0.17.0.dev0'
8080
81+ _PYPROJECT_METADATA_VERSION = tuple (map (int , pyproject_metadata .__version__ .split ('.' )[:2 ]))
8182
8283_NINJA_REQUIRED_VERSION = '1.8.2'
8384_MESON_REQUIRED_VERSION = '0.63.3' # keep in sync with the version requirement in pyproject.toml
@@ -244,6 +245,9 @@ class MesonBuilderError(Error):
244245
245246class Metadata (pyproject_metadata .StandardMetadata ):
246247 def __init__ (self , name : str , * args : Any , ** kwargs : Any ):
248+ if _PYPROJECT_METADATA_VERSION < (0 , 9 ):
249+ kwargs .pop ('license' , None )
250+ kwargs .pop ('license_files' , None )
247251 super ().__init__ (name , * args , ** kwargs )
248252 # Local fix for https://github.com/FFY00/python-pyproject-metadata/issues/60
249253 self .name = self ._validate_name (name )
@@ -759,7 +763,12 @@ def __init__(
759763 if license is None :
760764 raise pyproject_metadata .ConfigurationError (
761765 'Field "license" declared as dynamic but license is not specified in meson.build' )
762- self ._metadata .license = license
766+ # mypy is not happy when analyzing typing based on
767+ # pyproject-metadata < 0.9 where license needs to be of
768+ # License type. However, this code is not executed if
769+ # pyproject-metadata is older than 0.9 because then dynamic
770+ # license is not allowed.
771+ self ._metadata .license = license # type: ignore[assignment]
763772 if 'license-files' in self ._metadata .dynamic :
764773 self ._metadata .license_files = self ._meson_license_files
765774 else :
@@ -909,7 +918,7 @@ def _meson_license(self) -> Optional[str]:
909918 assert isinstance (value , str )
910919 if value == 'unknown' :
911920 return None
912- return canonicalize_license_expression (value )
921+ return str ( canonicalize_license_expression (value )) # str() is to make mypy happy
913922
914923 @property
915924 def _meson_license_files (self ) -> Optional [List [pathlib .Path ]]:
0 commit comments