Skip to content

Crossreferences to standard library in mypy docs, part 2 #7660

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

Merged
merged 3 commits into from
Oct 9, 2019

Conversation

hoefling
Copy link
Contributor

@hoefling hoefling commented Oct 8, 2019

Added references to the following documents:

  • builtin_types.rst
  • common_issues.rst
  • config_file.rst
  • dynamic_typing.rst

This is part of splitting up the changes in #7624 into more readable PRs.

@@ -254,8 +254,8 @@ For more information, see the :ref:`None and optional handling <none-and-optiona
section of the command line docs.

``no_implicit_optional`` (bool, default False)
Changes the treatment of arguments with a default value of None by not implicitly
making their type Optional.
Changes the treatment of arguments with a default value of ``None`` by not implicitly
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I suppose the verbatim formatting was forgotten here, so added the Optional ref as well.

Copy link
Member

Choose a reason for hiding this comment

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

+1

A comma-separated list of paths which should be checked by mypy if none are given on the command
line. Supports recursive file globbing using :doc:`library/glob`, where ``*`` (e.g. ``*.py``) matches
line. Supports recursive file globbing using :py:mod:`glob`, where ``*`` (e.g. ``*.py``) matches
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Please advise here. Both links lead to the same target: the glob module docs, but are rendered differently:

image

vs

image

Copy link
Member

Choose a reason for hiding this comment

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

I like the second better. So +1 to the change. (Do we use this :doc: style elsewhere, and does it get rendered so longwindedly there too? I think it's not needed.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There are a few :doc: roles that refer to standard library modules:

For more information see :doc:`official docs <python:library/dataclasses>`

Mypy supports Python :doc:`abstract base classes <library/abc>` (ABCs). Abstract classes

:doc:`ini file <python:library/configparser>` format. It should contain

abstract method or attribute. (See also :doc:`Python
abc module documentation <python:library/abc>`)

Do you suggest to replace them with the appropriate :mod: role?

Copy link
Member

Choose a reason for hiding this comment

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

It doesn't seem necessary, since those other places all specify link text.

We cannot hope to strive for 100% consistency everywhere.

You can use ``cast()`` (see chapter :ref:`casts`) or ``isinstance`` to
go from a general type such as ``object`` to a more specific
type (subtype) such as ``int``. ``cast()`` is not needed with
You can use :py:func:`~typing.cast` (see chapter :ref:`casts`) or :py:func:`isinstance` to
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have altered the rendering by including the parentheses to isinstance. Before:

image

After:

image

Both are functions - shouldn't both have parentheses in this case?

Copy link
Member

Choose a reason for hiding this comment

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

+1. The only time it's better not to add () to a function is when we're talking about the function object (e.g. in the context of creating an alias or accessing attributes).

Copy link
Member

@gvanrossum gvanrossum left a comment

Choose a reason for hiding this comment

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

Will merge as-is.

@@ -254,8 +254,8 @@ For more information, see the :ref:`None and optional handling <none-and-optiona
section of the command line docs.

``no_implicit_optional`` (bool, default False)
Changes the treatment of arguments with a default value of None by not implicitly
making their type Optional.
Changes the treatment of arguments with a default value of ``None`` by not implicitly
Copy link
Member

Choose a reason for hiding this comment

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

+1

A comma-separated list of paths which should be checked by mypy if none are given on the command
line. Supports recursive file globbing using :doc:`library/glob`, where ``*`` (e.g. ``*.py``) matches
line. Supports recursive file globbing using :py:mod:`glob`, where ``*`` (e.g. ``*.py``) matches
Copy link
Member

Choose a reason for hiding this comment

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

I like the second better. So +1 to the change. (Do we use this :doc: style elsewhere, and does it get rendered so longwindedly there too? I think it's not needed.)

You can use ``cast()`` (see chapter :ref:`casts`) or ``isinstance`` to
go from a general type such as ``object`` to a more specific
type (subtype) such as ``int``. ``cast()`` is not needed with
You can use :py:func:`~typing.cast` (see chapter :ref:`casts`) or :py:func:`isinstance` to
Copy link
Member

Choose a reason for hiding this comment

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

+1. The only time it's better not to add () to a function is when we're talking about the function object (e.g. in the context of creating an alias or accessing attributes).

@gvanrossum gvanrossum merged commit 54e3452 into python:master Oct 9, 2019
@hoefling hoefling deleted the stdlib-crossref-2 branch October 9, 2019 20:12
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.

2 participants