Search code examples
pythonlisttuplessetup.py

Should I use a tuple or list for classifiers in my setup.py?


I've got two Python projects. In the setup.py of one, my classifiers are inside square brackets:

classifiers=[
    'Development Status :: 5 - Production/Stable',
    'Natural Language :: English',
    'License :: OSI Approved :: Apache Software License',
    'Programming Language :: Python',
    'Programming Language :: Python :: 2.7',
    'Programming Language :: Python :: 3',
    'Programming Language :: Python :: 3.4',
    'Programming Language :: Python :: 3.5',
    'Programming Language :: Python :: 3.6',
    'Programming Language :: Python :: 3.7',
]

In the other, they are inside parentheses:

classifiers=(
    'Development Status :: 5 - Production/Stable',
    'Natural Language :: English',
    'License :: OSI Approved :: Apache Software License',
    'Programming Language :: Python',
    'Programming Language :: Python :: 2.7',
    'Programming Language :: Python :: 3',
    'Programming Language :: Python :: 3.4',
    'Programming Language :: Python :: 3.5',
    'Programming Language :: Python :: 3.6',
    'Programming Language :: Python :: 3.7',
)

I'm aware that one is a list and the other is a tuple, and I don't see any issue with using either, but I'd like to know, does it matter which format is used?


Solution

  • Historically, making it a tuple was not an option at all:

    While using a tuple is no longer an outright error, you will still get a warning when you run your setup:

    $ python setup.py sdist
    Warning: 'classifiers' should be a list, got type 'tuple'
    ...
    

    TL;DR

    Use a list instead of tuple for your classifiers.