Skip to content

Commit c962993

Browse files
Mention in the Any documentation how object is preferable (#19103)
This implements a suggestion in #9153 (comment), which I thought was a good idea. --------- Co-authored-by: Shantanu <[email protected]>
1 parent b4102f2 commit c962993

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

docs/source/dynamic_typing.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
.. _dynamic-typing:
22

3-
43
Dynamically typed code
54
======================
65

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

96+
.. _any-vs-object:
97+
9798
Any vs. object
9899
--------------
99100

docs/source/kinds_of_types.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ operations are permitted on the value, and the operations are only checked
4141
at runtime. You can use ``Any`` as an "escape hatch" when you can't use
4242
a more precise type for some reason.
4343

44+
This should not be confused with the
45+
:py:class:`object` type, which represents the set of all values.
46+
Unlike ``object``, ``Any`` introduces type unsafety — see
47+
:ref:`any-vs-object` for more.
48+
4449
``Any`` is compatible with every other type, and vice versa. You can freely
4550
assign a value of type ``Any`` to a variable with a more precise type:
4651

0 commit comments

Comments
 (0)