Skip to content

Builtin generic type annotations on Python 3.8 #245

Open
@Newbytee

Description

Describe the bug
While builtin generic type annotations for types such as contextvars.ContextVar were added in Python 3.9, they do not crash in Python 3.8. As such, it seems to me that they are safe to use in Python 3.8 and an error should not be raised. Right now, Vermin gives an error stating that builtin generic type annotations need Python 3.9.

To Reproduce
Try running for example this code in Python 3.8 and observe that it doesn't crash:

import contextvars
print(contextvars.ContextVar[str])

def test() -> contextvars.ContextVar[str]:
    print("hi")

test()

Expected behavior
Since these builtin generic type annotations do not crash on Python 3.8, I think there is an argument to make that they should be allowed.

Environment (please complete the following information):

  • 1.6.0

Additional context
To clarify, just disabling Vermin's evaluation of types is not a solution to this problem as there are other type hints which are not "backwards compatible" like this and cause issues such as the "new" union syntax.

With all that said, I'm open to being proven wrong.

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