setuptools_scm icon indicating copy to clipboard operation
setuptools_scm copied to clipboard

Request: adding type hints and py.typed to setuptools_scm

Open jamesbraza opened this issue 4 years ago • 13 comments

As I am sure the setuptools_scm maintainers are aware:

  • Type hints were added in PEP 484 in Python 3.5
  • Python3 <= 3.4 is basically deprecated Python 2.7 hangs on by a thread elsewhere

I use setuptools_scm as part of some type checked code (via mypy). From what I have seen, setuptools_scm:

  • Isn't type hinted
  • Doesn't have the requisite py.typed marker file per PEP 561
  • Supports Python 2.7 and 3.4+, per the tox.ini file

There is a similar ticket for setuptools: https://github.com/pypa/setuptools/issues/2345

Any thoughts on adding support for type hints?

Aside: I'm not sure how one can add type hints and maintain support for Python 2.7 and 3.4.


Workaround

In the meantime, I am adding the following to my setup.cfg section for mypy:

[mypy-setuptools_scm.*]
ignore_missing_imports = True

jamesbraza avatar Dec 06 '20 02:12 jamesbraza

Im happy to add typing after python 2.7 is dropped

Python 2.7 will be dropped when pip does

RonnyPfannschmidt avatar Dec 06 '20 03:12 RonnyPfannschmidt

Pip 21.0 dropped py2 support. This can be now done! 🥳

tuukkamustonen avatar May 07 '21 07:05 tuukkamustonen

python 2 support was dropped in version 6 of setuptools_scm

RonnyPfannschmidt avatar May 07 '21 08:05 RonnyPfannschmidt

i started adding some type hints, its still along way till py.typed tho

RonnyPfannschmidt avatar Jan 17 '22 20:01 RonnyPfannschmidt

@RonnyPfannschmidt Any chance to resume on that? Even partial types could help, we don't need 100% from start.

ssbarnea avatar Dec 25 '22 10:12 ssbarnea

There are some needed breaking changes after which it makes sense,

Im currently a bit stretched

RonnyPfannschmidt avatar Dec 25 '22 10:12 RonnyPfannschmidt

type annotations are added, the 8.x series will not export them yet

RonnyPfannschmidt avatar Sep 11 '23 15:09 RonnyPfannschmidt

More out of curiosity, why add type annotations and then not export them? Is it just to test out type annotations for some time?

jamesbraza avatar Oct 27 '23 20:10 jamesbraza

As soon as they are exported,the number of actions one can take for refactoring that count as breaking change increase

The typing closure for the configuration,scm versions and version schemes is currently very fuzzy and locking it in for externals would be a major paint

RonnyPfannschmidt avatar Oct 28 '23 04:10 RonnyPfannschmidt

Oh that makes sense, thank you for circling back! Appreciate the quick response too

jamesbraza avatar Oct 28 '23 05:10 jamesbraza

That being said, i Wish I wasn't quite as stretched so I could complete the work on this timely

RonnyPfannschmidt avatar Oct 28 '23 05:10 RonnyPfannschmidt

Just my 2 cent on this: As long as the API is stable, IMO it's fine if the type annotations change in an incompatible way. You could even see type annotation changes as fixes since the type annotation is then better as before and maybe even more correct 😄

kasium avatar Apr 09 '24 05:04 kasium

as im rather stretched in delivering certain refactorings i am hesitant to impose possile type anotation enforced breakage on downstreams, not that there arent many of them

RonnyPfannschmidt avatar Apr 09 '24 06:04 RonnyPfannschmidt