wntrblm / nox

Flexible test automation for Python
https://nox.thea.codes
Apache License 2.0
1.31k stars 150 forks source link

Reading Python classifiers from pyproject.toml #855

Open henryiii opened 4 days ago

henryiii commented 4 days ago

How would this feature be useful?

We could convert python classifiers to a Python version list.

Describe the solution you'd like

Here's the current way to do it:

ALL_PYTHONS = [
    c.split()[-1]
    for c in nox.project.load_toml("pyproject.toml")["project"]["classifiers"]
    if c.startswith("Programming Language :: Python :: 3.")
]

Describe alternatives you've considered

No response

Anything else?

No response

o-moe commented 16 hours ago

I just started utilizing nox and was looking for a way to get rid of the code duplication regarding the specified Python requirement from pyproject.toml and nox. For me, I was more looking into a way to use requires-python instead of the classifiers (since they are optional and requires-python is not). But this would work as well.

BTW: This could add great value to the documentation.

Keep up the great work!

henryiii commented 16 hours ago

I think it would be fine to fall back to that if classifier are missing, but classifiers have an upper bound, while you should never put an upper cap for requires-Python.