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

Stop suggesting MYPYPATH on missing imports #5950

Merged
merged 3 commits into from Nov 27, 2018

Conversation

Projects
None yet
2 participants
@Michael0x2a
Copy link
Collaborator

Michael0x2a commented Nov 25, 2018

This pull request replaces the "Perhaps setting MYPYPATH..." note with a link to https://mypy.readthedocs.io/en/latest/running_mypy.html#missing-imports

It also updates the docs to make that page a little more actionable: it now clearly distinguishes between different scenarios a user might find themselves in and gives concrete steps to try for each case.

It also modifies the docs to suggest that users try searching for or writing their stubs first and try silencing errors second.

Resolves #5241.

Stop suggesting MYPYPATH on missing imports
This pull request replaces the "Perhaps setting MYPYPATH..."
note with a link to
https://mypy.readthedocs.io/en/latest/running_mypy.html#missing-imports

It also updates the docs to make that page a little more actionable:
it now clearly distinguishes between different scenarios a user might
find themselves in, as well as concrete suggestions for each step.

It also modifies the docs to suggest that users try searching for or
writing their stubs first and try silencing errors second.

Resolves #5241.
@gvanrossum
Copy link
Member

gvanrossum left a comment

Great! Here are some suggestions.

2. Reading the :ref:`finding-imports` section below to make sure you
understand how exactly mypy searches for and finds modules and modify
how you're invoking mypy accordingly.
3. Adding the path to that module to the ``MYPYPATH`` environment variable.

This comment has been minimized.

@gvanrossum

gvanrossum Nov 25, 2018

Member

"path to that module" -> "directory containing that module (or containing its outermost ancestor package, if the module occurs in a package)"

(Not sure about the wording but I want to make sure people get that for a module inside a package they should add the directory containing the outermost package, not the name of the module or the name of its immediate parent package.)


1. Searching to see if there is a :ref:`PEP 561 compliant stub package <installed-packages>`.
corresponding to your third party library. Stub packages let you install
type hints independently from the library itself.

This comment has been minimized.

@gvanrossum

gvanrossum Nov 25, 2018

Member

Give a real-world example.

This comment has been minimized.

@gvanrossum
Show resolved Hide resolved docs/source/running_mypy.rst
:ref:`import discovery <config-file-import-discovery-per-module>` in config files.

3. To silence *all* missing import errors for *all* libraries in your codebase,
invoke mypy with the ``--ignore-missing-imports`` command line flag. We

This comment has been minimized.

@gvanrossum

gvanrossum Nov 25, 2018

Member

Maybe also mention the equivalent config option?

@Michael0x2a

This comment has been minimized.

Copy link
Collaborator

Michael0x2a commented Nov 25, 2018

@gvanrossum -- thanks for the feedback! I made all of the changes you suggested, except for the one about adding an example of a stubs package. There's some discussion about this on gitter, but the long and short of it was that I wasn't really able to find an example of a PEP 561 stubs package I felt entirely comfortable using.

I'm thinking of waiting until sqlalchemy-stubs is published on PyPI and submitting a PR that uses that as an example. Alternatively, I could submit a PR to typeshed or something containing a list of PEP 561 packages and link to that instead? That might require more coordination with @ethanhs + the typeshed folks though.

@gvanrossum
Copy link
Member

gvanrossum left a comment

LG! Adding ordered-set-stubs as example is optional.


1. Searching to see if there is a :ref:`PEP 561 compliant stub package <installed-packages>`.
corresponding to your third party library. Stub packages let you install
type hints independently from the library itself.

This comment has been minimized.

@gvanrossum

@Michael0x2a Michael0x2a merged commit b790539 into python:master Nov 27, 2018

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

@Michael0x2a Michael0x2a deleted the Michael0x2a:stop-recommending-mypypath branch Nov 27, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment