File tree Expand file tree Collapse file tree 2 files changed +6
-2
lines changed Expand file tree Collapse file tree 2 files changed +6
-2
lines changed Original file line number Diff line number Diff line change 1
1
.. _dynamic-typing :
2
2
3
-
4
3
Dynamically typed code
5
4
======================
6
5
@@ -94,6 +93,8 @@ third party libraries that mypy does not know about. This is particularly the ca
94
93
when using the :option: `--ignore-missing-imports <mypy --ignore-missing-imports> `
95
94
flag. See :ref: `fix-missing-imports ` for more information about this.
96
95
96
+ .. _any-vs-object :
97
+
97
98
Any vs. object
98
99
--------------
99
100
Original file line number Diff line number Diff line change @@ -39,7 +39,10 @@ A value with the ``Any`` type is dynamically typed. Mypy doesn't know
39
39
anything about the possible runtime types of such value. Any
40
40
operations are permitted on the value, and the operations are only checked
41
41
at runtime.
6418
You can use ``Any `` as an "escape hatch" when you can't use
42
- a more precise type for some reason.
42
+ a more precise type for some reason. This should not be confused with the
43
+ :py:class: `object ` type, which also represents any value, but in a type-safe
44
+ way; it's almost always preferable to use ``object `` instead of ``Any ``, if
45
+ you can do so without great difficulty — see :ref: `any-vs-object ` for more.
43
46
44
47
``Any `` is compatible with every other type, and vice versa. You can freely
45
48
assign a value of type ``Any `` to a variable with a more precise type:
You can’t perform that action at this time.
0 commit comments