Open GergelyKalmar opened 4 years ago
Sounds good to me. Would you be interested in contributing such hints? Maybe start at something modest, like setup()
as you say.
I'm also interested in giving a hand, given this would take quite some work.
Perhaps I could write it up, but it might take some more time then. As you're building on distutils
I guess I would need to dig a bit to make sure my implementation makes sense, even if just for setup()
. Although the distutils
interface seems to be documented okay – I'm not sure what traps to look out for. On the bright side there's at least no need for Python 2-style type hints given that you're not supporting that anymore.
If someone else wants to immerse themselves into this, I wouldn't mind. I'm still a bit behind type hinting my own codebase first anyways.
It's not a very friendly interface to type hint though with all the **attrs
catch-alls (https://github.com/python/cpython/blob/master/Lib/distutils/core.py#L57).
It's not a very friendly interface to type hint though with all the
**attrs
catch-alls (https://github.com/python/cpython/blob/master/Lib/distutils/core.py#L57).
Perhaps it's a good idea to use a stub file and annotate the setup()
function as if it had all the documented arguments?
That would have been my idea too. I'm pretty busy at the moment though and so I'm not sure I'd get to it anytime soon!
Late versions of the setuptools test suite will run mypy checks on the code, but there are many failed checks. To run the checks, use tox -- --mypy
. Here's a sample run:
It might be useful to add that in the meantime stubs were developed in typeshed: https://github.com/python/typeshed/pull/5762
It seems to be ready to be released, once it is released I think the issue can be closed.
With Python 3.12 dropping disutils, setuptools' oldest python supported version now being 3.8 and the typeshed's setuptools stubs having matured a lot, what do you think about setuptools providing its own typing information?
This is the general [precise and continuously updated] plan I would suggest:
pkg_resources
stubs from typeshedAny
) #4391Any
pkg_resources
as py.typed
(typeshed will remove the package 6 months later).setuptools
stubs from typeshed
6.1. ANN2
for setuptools module) https://github.com/pypa/setuptools/pull/4504ruff --select=ANN204
with ignore-fully-untyped = false
6.4. Fully type the setup
method and other **kwargs
typed in typeshedsetuptools
as py.typed
(typeshed will mark the stubs as "obsolete" for 6 months before removal).
We don't need to be fully typed, just to be on par with typeshed.
It seems that setuptools doesn't have type hints at the moment:
I think that adding type hints at least to the most common entrypoints (e.g.
setup
) would be great to have, considering that setuptools is quite an important part of the official Python ecosystem.