Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

py.typed not included in PyPI distribution #470

Closed
MaxwellPayne opened this issue Apr 19, 2023 · 3 comments · Fixed by #471
Closed

py.typed not included in PyPI distribution #470

MaxwellPayne opened this issue Apr 19, 2023 · 3 comments · Fixed by #471

Comments

@MaxwellPayne
Copy link
Contributor

What action do you want to perform

I'm attempting to import submodules of pytest_redis within my project, using version 3.0.1. Something like:

import pytest_redis.executor
import pytest_redis.factories

What are the results

When I run a mypy check on this file, I get the following errors:

tests/conftest.py:15: error: Skipping analyzing "pytest_redis.executor": module is installed, but missing library stubs or py.typed marker  [import]
    import pytest_redis.executor
    ^
tests/conftest.py:15: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
tests/conftest.py:15: error: Skipping analyzing "pytest_redis": module is installed, but missing library stubs or py.typed marker  [import]
    import pytest_redis.executor
    ^
tests/conftest.py:16: error: Skipping analyzing "pytest_redis.factories": module is installed, but missing library stubs or py.typed marker  [import]
    import pytest_redis.factories

What are the expected results

This seemed strange to me, since I noticed that this project has a py.typed file which should inform Mypy that this repo has type annotations in place. But when I looked in my local site-packages/pytest_redis directory, I see the following:

-rw-r--r--  1 max  staff   861 Apr 18 23:46 __init__.py
drwxr-xr-x  7 max  staff   224 Apr 19 01:08 __pycache__
-rw-r--r--  1 max  staff  1527 Apr 18 23:46 config.py
-rw-r--r--  1 max  staff   343 Apr 18 23:46 exception.py
drwxr-xr-x  6 max  staff   192 Apr 18 23:49 executor
drwxr-xr-x  7 max  staff   224 Apr 18 23:49 factories
-rw-r--r--  1 max  staff  5021 Apr 18 23:46 plugin.py

The lack of a local py.typed file misleads Mypy into believing that this package does not have type annotations, which is why it gives me those errors. When I manually touch a file with that name, Mypy then passes without error.

@fizyk
Copy link
Member

fizyk commented Apr 19, 2023

@MaxwellPayne are you aware of any validation I could employ to check whether the py.typed is the package or not? Just In case I break something in the future again...

@fizyk
Copy link
Member

fizyk commented Apr 19, 2023

Anyway, try 3.0.2

@MaxwellPayne
Copy link
Contributor Author

@fizyk Thanks for the quick turnaround! I updated my package version to the new one from PyPI, and I see the expected py.typed file now.

are you aware of any validation I could employ to check whether the py.typed is the package or not? Just In case I break something in the future again...

I suppose you could write some sort of CI validation script that executes a build, tar-extracts the dist/ artifact, then searches the resulting directory for py.typed and fails if not found. There might be a simpler way, however I'm pretty unfamiliar with the build process that uses MANIFEST.in so I can't speak to the most elegant solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants