Skip to content
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

generated _version.py contains invalid type annotations on <3.9 #912

Closed
exs-avianello opened this issue Sep 20, 2023 · 2 comments
Closed
Labels

Comments

@exs-avianello
Copy link

Hello! Thank you for all of the work on this package ❤️

I wanted to flag up that since setuptools_scm==8.0.1, the dynamically generated version file contains type hints that are only valid on python >=3.9

# file generated by setuptools_scm
# don't change, don't track in version control
__version__ = version = '0.55.1.dev4'  # type: str
__version_tuple__ = version_tuple = (0, 55, 1, 'dev4')  # type: tuple[int | str, ...]
(python 3.8)
> mypy version.py
version.py:4: error: Unexpected "..."  [misc]
version.py:4: error: "tuple" is not subscriptable, use "typing.Tuple" instead  [misc]
version.py:4: error: Incompatible types in assignment (expression has type "Tuple[int, int, int, str]", variable has type "Tuple[Union[int, str], Any]")  [assignment]
Found 3 errors in 1 file (checked 1 source file)

Unless specifically excluding the version file from type checking, I imagine that this is very likely to lead to broken CI/CD pipelines in most workflows.

I think that removing the inline type annotations from the version file (like in setuptools_scm<8.0.0) or adding a from __future__ import annotations at the top of the file would solve the problem

@exs-avianello
Copy link
Author

( Might be worth making sure to have a blank line under the from __future__ import annotations just in case users are running black on that file too :) )

# file generated by setuptools_scm
# don't change, don't track in version control
from __future__ import annotations

__version__ = version = "0.55.1.dev4"  # type: str
__version_tuple__ = version_tuple = (0, 55, 1, "dev4")  # type: tuple[int | str, ...]

@RonnyPfannschmidt
Copy link
Contributor

i wonder if this ought to be a mypy bug as well, i was under the impression the future import was just to stop evaluating, the comments aren't evaluated to begin with

i'll add the future import back

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants