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

Mypy error on python 3.8 on version generation #926

Closed
ralequi opened this issue Sep 21, 2023 · 7 comments
Closed

Mypy error on python 3.8 on version generation #926

ralequi opened this issue Sep 21, 2023 · 7 comments

Comments

@ralequi
Copy link

ralequi commented Sep 21, 2023

The current setuptools_scm generates an (mypy) invalid version.py for python 3.8.

The current version generates something like:

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

__version__ = version = '2.0.2.dev217'  # type: str
__version_tuple__ = version_tuple = (2, 0, 2, 'dev217')  # type: tuple[int | str, ...]

While previous version did something like:

# file generated by setuptools_scm
# don't change, don't track in version control
__version__ = version = '2.0.2.dev70'
__version_tuple__ = version_tuple = (2, 0, 2, 'dev70')

The new added typing is invalid in python 3.8's mypy:

$ mypy -p ${PYTHON_PACKAGE_NAME} --ignore-missing-imports
x/version.py:4: error: Unexpected "..."  [misc]
x/version.py:4: error: "tuple" is not subscriptable, use "typing.Tuple" instead  [misc]
x/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]

The commit defc575 introduced the bug (Jul 12 2023) by @RonnyPfannschmidt
and references issue #527

This is breaking many of my pipelines, and probably soon many other people's.
Please, consider a more flex typing while python 3.8 hasn't reached it's EOL.

Thank you, this package is great and helps a lot on my python's packages!

@ralequi
Copy link
Author

ralequi commented Sep 21, 2023

Just a note: I've tested this on pythons 3.8, 3.10, 3.11 and 3.12-rc. Only failing on 3.8
The python exact version i'm using is the one provided in docker hub

@RonnyPfannschmidt
Copy link
Contributor

seems like i made a mistake when testing the change, whats he mypy version
im under the impession i need to ad quotes even tho its already a comment

@ralequi
Copy link
Author

ralequi commented Sep 21, 2023

Thanks for your quick reply @RonnyPfannschmidt
Our failing setup versions are:

# mypy --version
mypy 1.5.1 (compiled: yes)

# python3 --version
Python 3.8.18

# cat /etc/os-release 
PRETTY_NAME="Debian GNU/Linux 11 (bullseye)"
[...]

@RonnyPfannschmidt
Copy link
Contributor

it seems like this happens only on mypy on python 3.8 itself, im going to replace it with a typing.Tuple for now

@ralequi
Copy link
Author

ralequi commented Sep 22, 2023

Thank you!

Going to test ASAP

RonnyPfannschmidt added a commit to RonnyPfannschmidt/setuptools_scm that referenced this issue Sep 22, 2023
@ralequi
Copy link
Author

ralequi commented Oct 6, 2023

Forgot to confirm, but the fix worked for me!
Thank you!

@RonnyPfannschmidt
Copy link
Contributor

@ralequi thanks for getting back 👍

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

No branches or pull requests

2 participants