Skip to content

Document stub-only packages incompatibility with MYPYPATH - #5428

Merged
gvanrossum merged 3 commits into
python:masterfrom
emmatyping:stubpathdoc
Aug 31, 2018
Merged

gvanrossum merged 3 commits into
python:masterfrom
emmatyping:stubpathdoc

Conversation

@emmatyping

Copy link
Copy Markdown
Member

Closes #5386.

@emmatyping
emmatyping requested a review from gvanrossum August 7, 2018 20:30

@Michael0x2a Michael0x2a left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some more broader comments:

  • Do we also need to update anything in this section of the docs? http://mypy.readthedocs.io/en/latest/running_mypy.html#how-imports-are-found

  • Do you think it might be a good idea to add instructions on using pip to create an editable install somewhere? I don't think it's a feature of pip a lot of people are familiar with, so it might be good to mention that's an alternative so that people aren't stuck when they realize they can't use MYPYPATH.

Comment thread docs/source/stubs.rst Outdated
Use the normal Python file name conventions for modules, e.g. ``csv.pyi``
for module ``csv``. Use a subdirectory with ``__init__.pyi`` for packages.
for module ``csv``. Use a subdirectory with ``__init__.pyi`` for packages. Note
that PEP 561 stub-only packages must be installed, and may not be pointed at

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe link to the PEP 561 page here? I think this is the first time we mention it on this page.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, that is a good idea.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(This is not done yet.)

Comment thread docs/source/installed_packages.rst Outdated
to disable searching.

Note that stub-only packages cannot be used with ``MYPYPATH``. If you want mypy
to find the package, it must be installed.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you clarify either here or somewhere else on this page what it means for a package to be "stub-only"? E.g. is a stub-only package a package that contains only .pyi files, or is a stub-only package one that has a name ending in -stub, contains only .pyi files, and contains a file named py.typed?

(And if you do decide to add the exact definition somewhere else on the page, we should probably link to that here.)

Similarly, maybe clarify what it means for a package to be "installed"?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think ideally the docs should have a glossary, and this would be good to add there. I think linking to PEP 561 https://www.python.org/dev/peps/pep-0561/#stub-only-packages in this case is enough.

@emmatyping

Copy link
Copy Markdown
Member Author

Do we also need to update anything in this section of the docs?

No, I don't think it is relevant there, that section doesn't talk a lot about MYPYPATH.

Do you think it might be a good idea to add instructions on using pip to create an editable install somewhere?

That might be a good idea, but I don't think an editable install is necessarily the best solution for everyone. That is why I want to say "install" over "editable install", because for most uses (those in a virtualenv) a regular install is better for general packaging purposes.

@Michael0x2a

Copy link
Copy Markdown
Collaborator

Do we also need to update anything in this section of the docs?

No, I don't think it is relevant there, that section doesn't talk a lot about MYPYPATH.

Is that what we want, though? If somebody is looking at that section, I imagine it's because they're running into issues getting their imports to resolve.

That might be due to a number of different issues -- one of which might include confusion on how exactly MYPYPATH works. In that case, perhaps it would be helpful for those readers if that section did talk more about MYPYPATH (or links to a page that does)?

Do you think it might be a good idea to add instructions on using pip to create an editable install somewhere?

That might be a good idea, but I don't think an editable install is necessarily the best solution for everyone. That is why I want to say "install" over "editable install", because for most uses (those in a virtualenv) a regular install is better for general packaging purposes.

Mkay, sounds good.

@emmatyping

Copy link
Copy Markdown
Member Author

Is that what we want, though? If somebody is looking at that section, I imagine it's because they're running into issues getting their imports to resolve.

OK, I will add something there too.

@Michael0x2a Michael0x2a left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM -- maybe Guido has more to add here?

@emmatyping

Copy link
Copy Markdown
Member Author

@gvanrossum when you look at #5517 tomorrow perhaps you could briefly take a look at this as well?

@gvanrossum

Copy link
Copy Markdown
Member

Will do!

@gvanrossum gvanrossum left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you finish this up so it can go in the release?

Comment thread docs/source/installed_packages.rst Outdated
Note that stub-only packages (defined in
`PEP 561 <https://www.python.org/dev/peps/pep-0561/#stub-only-packages>`_)
cannot be used with ``MYPYPATH``. If you want mypy to find the package, it must
be installed.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe explain that the reason is that the stubs for foo are in a folder named foo-stubs?

Comment thread docs/source/running_mypy.rst Outdated

.. note::

You cannot point to a PEP 561 package via the MYPYPATH, they must be

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

they -> it (or change the first half to plural :-).

Comment thread docs/source/stubs.rst Outdated
Use the normal Python file name conventions for modules, e.g. ``csv.pyi``
for module ``csv``. Use a subdirectory with ``__init__.pyi`` for packages.
for module ``csv``. Use a subdirectory with ``__init__.pyi`` for packages. Note
that PEP 561 stub-only packages must be installed, and may not be pointed at

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(This is not done yet.)

@gvanrossum
gvanrossum merged commit 8b0f022 into python:master Aug 31, 2018
@emmatyping
emmatyping deleted the stubpathdoc branch August 31, 2018 21:05
Akuli added a commit to Akuli/mypy that referenced this pull request May 14, 2021
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 this pull request may close these issues.

3 participants