Skip to content

Commit c2a8cc8

Browse files
authored
Simplify (#6)
* Simplify. Ditch the classifier tree entirely * Small formatting update * Switch to CalVer * Update contributing guide * Simplify tests * Update comments
1 parent 6e5d25e commit c2a8cc8

File tree

14 files changed

+120
-1267
lines changed

14 files changed

+120
-1267
lines changed

CONTRIBUTING.md

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,11 @@ matches the input source.
88
## Running linting
99
Run `make lint`.
1010

11-
## Rebuilding the auto-generated list of classifiers
12-
Run `make build`.
13-
1411
## Adding a new classifier
15-
To add a new classifier, edit `_internal/classifiers.py`, then rebuild the
16-
compiled list of classifiers with `make build`.
12+
To add a new classifier, add to the `classifiers` set in
13+
`trove_classifiers/__init__.py`.
1714

1815
## Deprecating a classifier
1916
To deprecate a classifier, move it from `classifiers` to
20-
`deprecated_classifiers` in `_internal/classifiers.py`, and list any new
17+
`deprecated_classifiers` in `trove_classifiers/__init__.py`, and list any new
2118
classifiers that may replace it.

Makefile

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,14 @@ BINDIR = $(PWD)/.state/env/bin
1010
# install various types of requirements
1111
$(BINDIR)/python -m pip install -r requirements/dev.txt
1212

13-
build: .state/env/pyvenv.cfg
14-
$(BINDIR)/python -m _internal.generator
15-
1613
test: .state/env/pyvenv.cfg
1714
$(BINDIR)/pytest
18-
$(eval TMPDIR := $(shell mktemp -d))
19-
$(BINDIR)/python -m _internal.generator --output $(TMPDIR)/test.py
20-
diff trove_classifiers/__init__.py $(TMPDIR)/test.py
15+
$(BINDIR)/python -m tester
2116

2217
lint: .state/env/pyvenv.cfg
23-
$(BINDIR)/black --check _internal tests
18+
$(BINDIR)/black --check tests tester trove_classifiers
2419

2520
reformat: .state/env/pyvenv.cfg
26-
$(BINDIR)/black _internal tests
21+
$(BINDIR)/black tests tester trove_classifiers
2722

2823
.PHONY: build test lint reformat

_internal/__init__.py

Whitespace-only changes.

_internal/classifiers.py

Lines changed: 0 additions & 1046 deletions
This file was deleted.

_internal/exceptions.py

Lines changed: 0 additions & 2 deletions
This file was deleted.

_internal/generator.py

Lines changed: 0 additions & 30 deletions
This file was deleted.

_internal/models.py

Lines changed: 0 additions & 77 deletions
This file was deleted.

_internal/templates/__init__.py.jinja2

Lines changed: 0 additions & 15 deletions
This file was deleted.

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
setup(
1313
name='trove-classifiers',
14-
version='1.0.0',
14+
version='2020.04.01',
1515
description="Cannonical source for classifiers on PyPI (pypi.org).",
1616
long_description=long_description,
1717
long_description_content_type="text/markdown",

tester/__init__.py

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
class InvalidClassifier(Exception):
2+
pass
3+
4+
5+
def trove_tester(classifiers, deprecated_classifiers):
6+
# Check the classifiers
7+
for classifier in classifiers:
8+
split = classifier.split(" :: ")
9+
10+
# Check if this is an invalid top-level classifier
11+
if len(split) == 1:
12+
raise InvalidClassifier(f"Top-level classifier {classifier!r} is invalid")
13+
14+
# Check if all parent classifiers are specified
15+
for i in range(2, len(split)):
16+
parent = " :: ".join(split[:i])
17+
if parent not in classifiers:
18+
raise InvalidClassifier(f"Classifier {parent!r} is missing")
19+
20+
# Check the sub-classifiers
21+
for sub in split:
22+
23+
# Check for whitespace
24+
if sub.strip().rstrip() != sub:
25+
raise InvalidClassifier(
26+
"Classifiers starting or ending with whitespace are invalid"
27+
)
28+
29+
# Check for private classifiers
30+
if sub.lower().startswith("private"):
31+
raise InvalidClassifier(
32+
"Classifiers starting with 'Private' are invalid"
33+
)
34+
35+
# Check for stray colons
36+
if ":" in sub:
37+
raise InvalidClassifier("Classifiers containing ':' are invalid")
38+
39+
# Check the deprecated classifiers
40+
for deprecated_classifier, deprecated_by in deprecated_classifiers.items():
41+
42+
# Check if the classifier is in both lists
43+
if deprecated_classifier in classifiers:
44+
raise InvalidClassifier(
45+
f"Classifier {deprecated_classifier!r} in both valid and deprecated classifiers"
46+
)
47+
48+
# Check if all deprecated_by classifiers exist
49+
for new_classifier in deprecated_by:
50+
if new_classifier not in classifiers:
51+
raise InvalidClassifier(f"Classifier {new_classifier!r} does not exist")
52+
53+
print("All classifiers passed :)")

0 commit comments

Comments
 (0)