vermin icon indicating copy to clipboard operation
vermin copied to clipboard

Builtin generic type annotations on Python 3.8

Open Newbytee opened this issue 2 years ago • 1 comments

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.

Newbytee avatar Dec 08 '23 15:12 Newbytee

Thank you for bringing this to my attention. There might be something that needs to change here since I see, myself, that it runs perfectly on Python 3.8, too.

netromdk avatar Sep 25 '25 08:09 netromdk