py.typed file missing in 1.x versions
HugoJP1 opened this issue · 5 comments
Hello, have attempted to bump sse-starlette in my repository to 1.1.1 (upgrading from 0.10.3), and I have got the following error:
error: Skipping analyzing "sse_starlette.sse": module is installed, but missing library stubs or py.typed marker
note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
error: Skipping analyzing "sse_starlette.sse": module is installed, but missing library stubs or py.typed marker
I tried downgrading to 1.1.0 and then 1.0.0, and they all have the same issue. Looking into the bundle as downloaded from pypi, the py.typed
file is no longer being included.
See downloaded bundle for 0.10.3:
I had a look at the code to see if there was anything obvious which had changed from the previous version which could cause this behaviour, and the setup.py
and Manifest.in
files seem correct to me. The only thing is that maybe MANIFEST.in
should be uppercase, but I don't see how that could really cause a problem.
Thanks @sysid ! I retested with 1.1.3 and I'm still getting the same issue with mypy, even though I can now see the py.typed
file in the directory.
Did a bit of digging, and found that it was actually not appearing in the installed package in my virtual environment.
Not too sure how it was working before, but looking at PEP 561 (https://peps.python.org/pep-0561/)
Package maintainers who wish to support type checking of their code MUST add a marker file named py.typed to their package supporting typing. This marker applies recursively: if a top-level package includes it, all its sub-packages MUST support type checking as well. To have this file installed with the package, maintainers can use existing packaging options such as package_data in distutils, shown below.
Distutils option example:
setup( ..., package_data = { 'foopkg': ['py.typed'], }, ..., )
So I think that setup.py needs to be updated too, similarly to how starlette is set up (https://github.com/encode/starlette/blob/master/setup.py#L37), potentially both with package_data
and include_package_data
.
This is annoying. I have no idea why the file does not get installed.
It is included in both packages in https://pypi.org/project/sse-starlette/#files, but does not get installed. Any ideas are welcome.
I will let you know if I get any ideas.