Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
ofek committed Nov 9, 2024
1 parent 61aa299 commit 58c456a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 6 additions & 2 deletions backend/src/hatchling/metadata/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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)

Expand Down
4 changes: 2 additions & 2 deletions tests/backend/metadata/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit 58c456a

Please sign in to comment.