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

Inline types are not exposed to users #214

Closed
AlexWaygood opened this issue Mar 30, 2023 · 3 comments · Fixed by #215
Closed

Inline types are not exposed to users #214

AlexWaygood opened this issue Mar 30, 2023 · 3 comments · Fixed by #215

Comments

@AlexWaygood
Copy link

Hi!

I'm a maintainer over at typeshed, where we have stubs for dj-database-url. It looks like you recently added inline types and a py.typed file, which is great! This means that we can hopefully soon remove our stubs from typeshed.

Unfortunately, your py.typed file isn't properly exposing your inline types to users of the package. If I install dj-database-url==1.3.0 and run mypy on a file containing just this:

import dj_database_url

Then this is the output from mypy:

repro.py:1: error: Library stubs not installed for "dj_database_url"  [import]
repro.py:1: note: Hint: "python3 -m pip install types-dj-database-url"
repro.py:1: note: (or run "mypy --install-types" to install all missing stub packages)
repro.py:1: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
Found 1 error in 1 file (checked 1 source file)

The reason for this is that dj-database-url is currently a single-file project. Unfortunately, PEP 561 doesn't provide a way for single-file projects to add a py.typed file to their project. In order for the py.typed file to be recognised by type checkers, you'd need to convert this project into a package (with the py.typed file inside the package). If you did that (and specified package_data in setup.py to ensure that the file was included in uploads to PyPI), then type checkers would see the py.typed file, and know to look for inline types in dj-database-url.

Would you consider making dj-database-url into a package? If dj-database-url remains a single-file project, then unfortunately the py.typed file you already have in this repo serves little purpose, and may as well be deleted :/

Cc. @palfrey, who authored #198, and @XF-FW, who originally contributed the stubs to typeshed :)

@palfrey
Copy link
Member

palfrey commented Apr 2, 2023

Sounds good to me. #215 implements this, and explicitly tests the mypy test case works. @mattseymour?

@mattseymour
Copy link
Contributor

Fixed as of release 2.0.0

@AlexWaygood
Copy link
Author

Thanks @palfrey and @mattseymour! Can confirm that the py.typed file is now included in the PyPI release, which led to our typeshed automation successfully being triggered: python/typeshed#10094

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.

3 participants