Skip to content

Mypy error on python 3.8 on version generation #926

@ralequi

Description

@ralequi

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions