intgr / drf-yasg-stubs

Typing stubs for drf-yasg library (PEP 484 stubs for Mypy and PyCharm)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Uses "Literal" from typing which is 3.8+ only

palfrey opened this issue · comments

See https://docs.python.org/3/library/typing.html#typing.Literal

I think the project should either document the Python 3.8 requirement or remove it and test against earlier versions.

Thanks for all your work here!

This is true, but should not cause any issues for users even with Python 3.7 or earlier.

The .pyi files are never executed by the Python interpreter itself. They are read by third party type-checking packages, like mypy. If you use mypy on Python 3.7, it has built-in knowledge of typing.Literal even if the interpreter doesn't.

If you're having problems with earlier Python versions, please describe your setup.

In a project where I've got a slightly hacked version of the views.pyi (to fix #2) I get the following unless I remove the Literal references. This is with mypy called as MYPYPATH=stubs mypy .. OTOH, this doesn't occur with the stock stubs, so I think this is just a local stubs weirdness.

stubs/drf_yasg/views.pyi:5: error: Module 'typing' has no attribute 'Literal'