@@ -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 )
@@ -758,7 +762,12 @@ def __init__(
758762                if  license  is  None :
759763                    raise  pyproject_metadata .ConfigurationError (
760764                        'Field "license" declared as dynamic but license is not specified in meson.build' )
761-                 self ._metadata .license  =  license 
765+                 # mypy is not happy when analyzing typing based on 
766+                 # pyproject-metadata < 0.9 where license needs to be of 
767+                 # License type.  However, this code is not executed if 
768+                 # pyproject-metadata is older than 0.9 because then dynamic 
769+                 # license is not allowed. 
770+                 self ._metadata .license  =  license   # type: ignore[assignment] 
762771            if  'license-files'  in  self ._metadata .dynamic :
763772                self ._metadata .license_files  =  self ._meson_license_files 
764773        else :
@@ -908,7 +917,7 @@ def _meson_license(self) -> Optional[str]:
908917        assert  isinstance (value , str )
909918        if  value  ==  'unknown' :
910919            return  None 
911-         return  canonicalize_license_expression (value )
920+         return  str ( canonicalize_license_expression (value ))  # str() is to make mypy happy 
912921
913922    @property  
914923    def  _meson_license_files (self ) ->  List [pathlib .Path ]:
0 commit comments