-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a lint check to ensure classifiers (and other metadata values) are valid #9499
Comments
Is there a tool for this? |
Hmm... Maybe @di would know. |
I don't know if there's a tool, but it's planned for In the meantime, Trove classifiers can be checked using https://pypi.org/project/trove-classifiers/ Something along the lines of: from trove_classifiers import classifiers # pip install trove-classifiers
BAD_CLASSIFIERS = {
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Topic :: Software Development :: Build Tools",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3 :: Only" # missing comma!
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
}
GOOD_CLASSIFIERS = {
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Topic :: Software Development :: Build Tools",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3 :: Only", # fixed comma
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
}
print(BAD_CLASSIFIERS <= classifiers) # False
print(GOOD_CLASSIFIERS <= classifiers) # True Alternatively, For example, using some Unix subset piping: $ python -m trove_classifiers > all.txt
$ python setup.py --classifiers > ours.txt
$ comm -23 <(sort -n ours.txt|uniq) <(sort -n all.txt|uniq) | head -1
Programming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.6
$ # Now fix setup.py
$ edit setup.py
$ python setup.py --classifiers > ours.txt
$ comm -23 <(sort -n ours.txt|uniq) <(sort -n all.txt|uniq) | head -1
$ And put a test to ensure the subset output is empty. (Could probably ditch the |
It should not be too difficult to write a pre-commit hook wrapping trove-classifiers. I wonder if someone has done it already. |
Yes, eventually |
We do run Line 312 in e17ddea
pip/.azure-pipelines/jobs/package.yml Line 29 in e17ddea
|
Pip 21.0 has now been released.
One issue, around the classifiers (a previous commit had left them incorrect). We should probably have a lint check that the classifiers are valid, to avoid this sort of issue in the future.
Originally posted by @pfmoore in #9282 (comment)
The text was updated successfully, but these errors were encountered: