-
-
Notifications
You must be signed in to change notification settings - Fork 866
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
Missing py.typed declaration? #193
Comments
Hmmm, we definitely want our type annotations to be discoverable by mypy. Do you think that this is something you'd be able to tackle? :) |
Did you properly install the module via pip? Hope this helps or makes sense :) |
It looks like we need a single |
Basically -- that marker file plus a package_data entry seems to have done the trick. |
Hey all, I just did There is still no Consequently, mypy still can't find types for httpx. From what I can tell, this PR was merged before 0.7.2 was released, so this should work in v0.7.2. If this is the case, this issue needs to be reopened. |
Yep, verified this is a bug. We need to add an entry to MANIFEST.in. @florimondmanca can we get this done before release? |
@sethmlarson Sure :) I’m curious why package_data isn’t enough to include the py.typed file, though. It has worked for me in a few other projects. |
That was my big question too, weird. |
Thanks for reporting this @kylebebak, it'll be fixed in 0.7.3! :) |
Right on, thanks all! @sethmlarson @florimondmanca |
@kylebebak Thank you, we appreciate your kind words! 🙇♂️ |
I think this is still an issue in 0.7.4 -- not sure why, but
|
Update: If you check out the repo and install from the local directory (either master or 0.7.4), the file is there. It's not there if you install via from pypi pip, nor is it in the tarball that's on pypi (https://pypi.org/project/httpx/#files). |
Before we mark this as closed again I guess we'll have to test by uploading the sdist and wheel to test PyPI and then installing from there. I think all we need is a modification to |
That’s what my testing indicates, but /shrug.
…On Thu, Oct 3, 2019 at 6:25 PM Seth Michael Larson ***@***.***> wrote:
Before we mark this as closed again I guess we'll have to test by
uploading the sdist and wheel to test PyPI and then installing from there.
I think all we need is a modification to MANIFEST.in? 🤷♂
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#193?email_source=notifications&email_token=AAKC45WCNM3X3LO53NR6FSTQM2LQJA5CNFSM4IJTP272YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEAKCLRI#issuecomment-538191301>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAKC45XIT3SFQRGF5Q3EMDLQM2LQJANCNFSM4IJTP27Q>
.
|
Related: It's a bit of a gross hack that we need a Is there anything productive that we could do to push for a nicer alternative to become adopted in whichever of Python/MyPy/PyPI this is relevant too? (Eg. A top-level |
I don't like that this file is required either (that said, I'm not very familiar with how mypy searches for types, and I'm betting there's a good reason they decided on using a marker file for packages).
I don't think they'll be changing this any time soon... |
I’d bet that too, but I can’t seem to find where this was discussed. PEP 561 doesn’t mention alternatives nor does it have a « Rejected ideas » section that we’d typically find in PEPs about public APIs. I think scraping the web (or just GitHub) for pages mentioning « Add py.types » or « fix type annotations distribution » would be an interesting experiment to try and gauge how unintuitive the py.typed file is. |
Out of curiosity, I compared the usage of It seems Pyre doesn't use # Can also be passed via a private config file.
pyre --search-path=venv/lib/python3.7/site-packages/ So instead of requiring package authors mark the package as typing-ready and have the type checker auto-discover those, Pyre switches the responsability on the user to tell Pyre where it should look for type annotations. Proof of concept: Pyre was able to use typing data from My main theory of why a special marker file was used is to increase performance. Pyre builds are very slow (30s-ish for a single-module project only with In terms of productivity, we could push for something like |
Just following up -- this looks to be fully resolved as of 0.7.5. Thanks! |
This commit adds a py.typed file, which marks the package as having type information available. For more information, see https://mypy.readthedocs.io/en/stable/installed_packages.html#making-pep-561-compatible-packages The zip_safe seems to be [still necessary](encode/httpx#193 (reference)), even though it is [deprecated](python/mypy#8802).
This is about the only discussion I found on this topic, but it seems true that adding that file is needed for mypy.
Importing packages can be quite expensive, so I guess it is about performance, feels strange indeed. |
This commit adds a py.typed file, which marks the package as having type information available. For more information, see https://mypy.readthedocs.io/en/stable/installed_packages.html#making-pep-561-compatible-packages The zip_safe seems to be [still necessary](encode/httpx#193 (reference)), even though it is [deprecated](python/mypy#8802).
mypy
is complaining about not being able to find type annotations forhttpx
:error: Cannot find module named 'httpx'
I'm somewhat new to using type annotations/static type checking in Python, but from the mypy documentation here it looks like there may be a missing declaration in
setup.py
?The text was updated successfully, but these errors were encountered: