8000 Mention in the Any documentation how object is preferable by wyattscarpenter · Pull Request #19103 · python/mypy · GitHub
[go: up one dir, main page]

Skip to content

Mention in the Any documentation how object is preferable #19103

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 2 additions & 1 deletion docs/source/dynamic_typing.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
.. _dynamic-typing:


Dynamically typed code
======================

Expand Down Expand Up @@ -94,6 +93,8 @@ third party libraries that mypy does not know about. This is particularly the ca
when using the :option:`--ignore-missing-imports <mypy --ignore-missing-imports>`
flag. See :ref:`fix-missing-imports` for more information about this.

.. _any-vs-object:

Any vs. object
--------------

Expand Down
5 changes: 4 additions & 1 deletion docs/source/kinds_of_types.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ A value with the ``Any`` type is dynamically typed. Mypy doesn't know
anything about the possible runtime types of such value. Any
operations are permitted on the value, and the operations are only checked
at runtime. You can use ``Any`` as an "escape hatch" when you can't use
a more precise type for some reason.
a more precise type for some reason. This should not be confused with the
:py:class:`object` type, which also represents any value, but in a type-safe
way; it's almost always preferable to use ``object`` instead of ``Any``, if
you can do so without great difficulty — see :ref:`any-vs-object` for more.

``Any`` is compatible with every other type, and vice versa. You can freely
assign a value of type ``Any`` to a variable with a more precise type:
Expand Down
0