diff --git a/backend/src/hatchling/metadata/core.py b/backend/src/hatchling/metadata/core.py index 9583907d5..14b29d069 100644 --- a/backend/src/hatchling/metadata/core.py +++ b/backend/src/hatchling/metadata/core.py @@ -4,8 +4,8 @@ import sys from contextlib import suppress from copy import deepcopy -from typing import TYPE_CHECKING, Any, Generic, cast from functools import cached_property +from typing import TYPE_CHECKING, Any, Generic, cast from hatchling.metadata.utils import ( format_dependency, @@ -100,7 +100,7 @@ def core_raw_metadata(self) -> dict[str, Any]: @cached_property def dynamic(self) -> list[str]: # Here we maintain a copy of the dynamic fields from `self.core raw metadata`. - # This property should never be mutated. In contrast, the fields in + # This property should never be mutated. In contrast, the fields in # `self.core.dynamic` are depopulated on the first evaulation of `self.core` # or `self.version` as the actual values are computed. dynamic = self.core_raw_metadata.get('dynamic', []) @@ -391,7 +391,7 @@ def name(self) -> str: return normalize_project_name(self.raw_name) @cached_property - def version(self) -> str: + def version(self) -> str | None: """ https://peps.python.org/pep-0621/#version """ @@ -404,6 +404,8 @@ def version(self) -> str: 'if `version` is in field `project.dynamic`' ) raise ValueError(message) + else: + return None else: if 'version' in self.dynamic: message = ( @@ -901,6 +903,7 @@ def classifiers(self) -> list[str]: verify_classifiers = not os.environ.get('HATCH_METADATA_CLASSIFIERS_NO_VERIFY') if verify_classifiers: import bisect + import trove_classifiers known_classifiers = trove_classifiers.classifiers | self._extra_classifiers