Closed nekonoshiri closed 4 years ago
Thanks nekonoshiri for your input, much appreciated!
I am not an expert on mypy
, but when I run mypy --python-executable /path/to/python ./sse_starlette
in the project directory I cannot reproduce your output (Actually there is no output at all, mypy
returns with code 0).
Can you tell me how to reproduce your output, please?
Sorry for the lack of explanation. Maybe the error occurs when installing this package by pip.
To reproduce I tried:
# I use virtualenv for reproducing environment, just to make sure
$ mkdir tmp; cd tmp
$ virtualenv -p python3.8 .
$ source bin/activate
$ pip install mypy==0.782 sse-starlette==0.3.4
$ echo "from sse_starlette import ServerSentEvent" > tmp.py
$ mypy tmp.py
Output:
tmp.py:1: error: Skipping analyzing 'sse_starlette': found module but no type hints or library stubs
tmp.py:1: note: See https://mypy.readthedocs.io/en/latest/running_mypy.html#missing-imports
Found 1 error in 1 file (checked 1 source file)
Then:
$ pip uninstall sse-starlette
$ pip install git+https://github.com/nekonoshiri/sse-starlette.git@add-py-typed
$ mypy tmp.py
Output:
Success: no issues found in 1 source file
https://docs.python.org/3/distutils/sourcedist.html#specifying-the-files-to-distribute
encode/httpx#193
According to the above, we also need to edit MANIFEST.in
file if it exists, I think.
Thanks nekonoshiri for your contribution!
My mypy no longer get error. Thanks!
What
I added starlette/py.typed file and update setup.py to include "package_data" line.
Why
I tried to use sse-starlette with mypy, but it claims
Skipping analyzing 'sse_starlette.sse': found module but no type hints or library stubs
.I found that's probably because of lack of py.typed file (PEP 561).