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

Add missing py.typed File #2089

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

max-muoto
Copy link

@max-muoto max-muoto commented Apr 27, 2024

Currently the lack of a py.typed file means that in VSCode the default bundled Django stubs (derived from djagno-types) are prioritized). This can make it quite confusing (for Pyright users) why you're seeing different results when running the Pyright CLI versus Pyright's type-checking in VSCode.

For reference, one is present in Djagno-Types as well: https://github.com/sbdchd/django-types

@sobolevn
Copy link
Member

sobolevn commented Apr 27, 2024

Sorry, I am not a pyright user. I cannot review :(

@max-muoto
Copy link
Author

Sorry, I am not a pyright user. I cannot review :(

Any other reviewers I could possibly ping?

@sobolevn sobolevn requested review from intgr and flaeppe April 28, 2024 07:08
@flaeppe
Copy link
Member

flaeppe commented Apr 28, 2024

I don't use pyright either. Does this change affect any other type checker, if not, could we merge and try it out?

@intgr
Copy link
Collaborator

intgr commented Apr 28, 2024

in VSCode the default bundled Django stubs (derived from djagno-types) are prioritized).

According to PEP 561, stubs-only packages don't need to include py.typed.

Note that for stub-only packages adding a py.typed marker is not needed since the name *-stubs is enough to indicate it is a source of typing information.

Did you try that this actually fixes the issue?

I wasn't aware that VSCode or pyright bundle the django-types package. I'm willing to consider work-around hacks, but this is a problem caused by VSCode/pyright first and foremost. I think manually installed stubs should override the defaults. Please open an issue for them and see what they think. In any case, they are in a better position to suggest what the appropriate solution is.

@Viicos
Copy link
Contributor

Viicos commented Apr 30, 2024

This is an existing issue on the Pylance side: microsoft/pylance-release#5031, so indeed not related to the missing py.typed marker which is not required for stubs.

@max-muoto
Copy link
Author

From what I can tell, while it isn't required, it is a way of at least tricking Pylance into prioritizing it.

@intgr intgr added the pyright Related to pyright type checker label Apr 30, 2024
@intgr
Copy link
Collaborator

intgr commented Apr 30, 2024

OK, per issue linked by Viicos, this has been reported upstream and there hasn't been any progress for months.

But did you test that this solves the issue with django-stubs? Usually it's also needed to change setup.py to ensure py.typed is included in the package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pyright Related to pyright type checker
Development

Successfully merging this pull request may close these issues.

5 participants