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
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
revisited dynamic_typing.rst
Signed-off-by: Oleg Höfling <oleg.hoefling@gmail.com>
  • Loading branch information
hoefling committed Oct 8, 2019
commit 943f159c65d3c8e7501c3f2927f1a8e7ca701b2e
12 changes: 6 additions & 6 deletions docs/source/dynamic_typing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ less effective, unless you are careful.
Any vs. object
--------------

The type ``object`` is another type that can have an instance of arbitrary
type as a value. Unlike ``Any``, ``object`` is an ordinary static type (it
The type :py:class:`object` is another type that can have an instance of arbitrary
type as a value. Unlike ``Any``, :py:class:`object` is an ordinary static type (it
is similar to ``Object`` in Java), and only operations valid for *all*
types are accepted for ``object`` values. These are all valid:
types are accepted for :py:class:`object` values. These are all valid:

.. code-block:: python

Expand All @@ -80,7 +80,7 @@ operations:
n = 1 # type: int
n = o # Error!

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).

go from a general type such as :py:class:`object` to a more specific
type (subtype) such as ``int``. :py:func:`~typing.cast` is not needed with
dynamically typed values (values with type ``Any``).
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy