From 4e327ef0a8ce22358c6d261cc6c03c2289cb011b Mon Sep 17 00:00:00 2001 From: Talley Lambert Date: Wed, 20 Mar 2024 13:02:19 -0400 Subject: [PATCH 1/2] allow v2.3 in metadataversion, fallback to any string --- src/npe2/manifest/_package_metadata.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/npe2/manifest/_package_metadata.py b/src/npe2/manifest/_package_metadata.py index ffe24f8b..04efc8e9 100644 --- a/src/npe2/manifest/_package_metadata.py +++ b/src/npe2/manifest/_package_metadata.py @@ -12,7 +12,7 @@ # https://packaging.python.org/specifications/core-metadata/ -MetadataVersion = Literal["1.0", "1.1", "1.2", "2.0", "2.1", "2.2"] +MetadataVersion = Literal["1.0", "1.1", "1.2", "2.0", "2.1", "2.2", "2.3"] _alphanum = "[a-zA-Z0-9]" PackageName = constr(regex=f"^{_alphanum}[a-zA-Z0-9._-]*{_alphanum}$") @@ -30,7 +30,9 @@ class PackageMetadata(BaseModel): class Config: extra = Extra.ignore - metadata_version: MetadataVersion = Field( + # allow str as a fallback in case the metata-version specification has been + # updated and we haven't updated the code yet + metadata_version: MetadataVersion | str = Field( "1.0", description="Version of the file format" ) name: PackageName = Field( # type: ignore From 57f7cca17c62d2395e5b838e358c14b48fe7aec0 Mon Sep 17 00:00:00 2001 From: Talley Lambert Date: Wed, 20 Mar 2024 13:11:01 -0400 Subject: [PATCH 2/2] fix typing --- src/npe2/manifest/_package_metadata.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/npe2/manifest/_package_metadata.py b/src/npe2/manifest/_package_metadata.py index 04efc8e9..4f7582c4 100644 --- a/src/npe2/manifest/_package_metadata.py +++ b/src/npe2/manifest/_package_metadata.py @@ -32,7 +32,7 @@ class Config: # allow str as a fallback in case the metata-version specification has been # updated and we haven't updated the code yet - metadata_version: MetadataVersion | str = Field( + metadata_version: Union[MetadataVersion, str] = Field( "1.0", description="Version of the file format" ) name: PackageName = Field( # type: ignore