File tree Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -89,6 +89,23 @@ This example accidentally calls ``sort()`` instead of :py:func:`sorted`:
89
89
90
90
x = sort([3 , 2 , 4 ]) # Error: Name "sort" is not defined [name-defined]
91
91
92
+
93
+ Check that a variable is not used before it's defined [used-before-def]
94
+ -----------------------------------------------------------------------
95
+
96
+ Mypy will generate an error if a name is used before it's defined.
97
+ While the name-defined check will catch issues with names that are undefined,
98
+ it will not flag if a variable is used and then defined later in the scope.
99
+ used-before-def check will catch such cases.
100
+
101
+ Example:
102
+
103
+ .. code-block :: python
104
+
105
+ print (x) # Error: Name "x" is used before definition [used-before-def]
106
+ x = 123
107
+
108
+
92
109
Check arguments in calls [call-arg]
93
110
-----------------------------------
94
111
@@ -430,7 +447,7 @@ Example:
430
447
# Error: Incompatible types (expression has type "float",
431
448
# TypedDict item "x" has type "int") [typeddict-item]
432
449
p: Point = {' x' : 1.2 , ' y' : 4 }
433
-
450
+
434
451
Check TypedDict Keys [typeddict-unknown-key]
435
452
--------------------------------------------
436
453
You can’t perform that action at this time.
0 commit comments