Skip to content

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

Closed
@exs-avianello

Description

@exs-avianello

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions