diff --git a/backend/src/hatchling/metadata/core.py b/backend/src/hatchling/metadata/core.py index 743dd0fd5..23bba1905 100644 --- a/backend/src/hatchling/metadata/core.py +++ b/backend/src/hatchling/metadata/core.py @@ -962,7 +962,7 @@ def classifiers(self) -> list[str]: message = 'Field `project.classifiers` must be an array' raise TypeError(message) - verify_classifiers = not os.environ.get("HATCH_NO_VERIFY_TROVE_CLASSIFIERS") + verify_classifiers = not os.environ.get('HATCH_METADATA_CLASSIFIERS_NO_VERIFY') if verify_classifiers: import trove_classifiers @@ -979,7 +979,11 @@ def classifiers(self) -> list[str]: message = f'Classifier #{i} of field `project.classifiers` must be a string' raise TypeError(message) - if not self.__classifier_is_private(classifier) and verify_classifiers and classifier not in known_classifiers: + if ( + not self.__classifier_is_private(classifier) + and verify_classifiers + and classifier not in known_classifiers + ): message = f'Unknown classifier in field `project.classifiers`: {classifier}' raise ValueError(message) diff --git a/tests/backend/metadata/test_core.py b/tests/backend/metadata/test_core.py index 3673d770c..2795c694d 100644 --- a/tests/backend/metadata/test_core.py +++ b/tests/backend/metadata/test_core.py @@ -899,14 +899,14 @@ def test_entry_not_string(self, isolation): _ = metadata.core.classifiers def test_entry_unknown(self, isolation, monkeypatch): - monkeypatch.delenv("HATCH_NO_VERIFY_TROVE_CLASSIFIERS", False) + monkeypatch.delenv('HATCH_METADATA_CLASSIFIERS_NO_VERIFY', False) metadata = ProjectMetadata(str(isolation), None, {'project': {'classifiers': ['foo']}}) with pytest.raises(ValueError, match='Unknown classifier in field `project.classifiers`: foo'): _ = metadata.core.classifiers def test_entry_unknown_no_verify(self, isolation, monkeypatch): - monkeypatch.setenv("HATCH_NO_VERIFY_TROVE_CLASSIFIERS", "1") + monkeypatch.setenv('HATCH_METADATA_CLASSIFIERS_NO_VERIFY', '1') classifiers = [ 'Programming Language :: Python :: 3.11', 'Programming Language :: Python :: 3.11',