Commit 8b30913
authored
[used before def] rework builtin handling (#14483)
When doing multiple passes, in the example below, `range` will refer to
current's module range. When doing a single pass, `range` will refer to
`builtins.range`:
```python
_range = range
_C = C # error: Name "C" is used before definition
class range: pass
class C: pass
```
Instead of looking at the output of semanal to check if a variable is
resolving to a `builtins` package, we can just check if it's part of
builtins module.
Fixes #14476.1 parent eee3a2a commit 8b30913
File tree
3 files changed
+27
-8
lines changed- mypy
- test-data/unit
3 files changed
+27
-8
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2359 | 2359 | | |
2360 | 2360 | | |
2361 | 2361 | | |
2362 | | - | |
| 2362 | + | |
| 2363 | + | |
| 2364 | + | |
| 2365 | + | |
2363 | 2366 | | |
2364 | 2367 | | |
2365 | 2368 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| 30 | + | |
30 | 31 | | |
31 | 32 | | |
32 | 33 | | |
33 | | - | |
34 | 34 | | |
35 | 35 | | |
| 36 | + | |
36 | 37 | | |
37 | 38 | | |
38 | 39 | | |
| |||
286 | 287 | | |
287 | 288 | | |
288 | 289 | | |
289 | | - | |
290 | | - | |
291 | | - | |
292 | | - | |
293 | 290 | | |
294 | 291 | | |
295 | 292 | | |
| |||
314 | 311 | | |
315 | 312 | | |
316 | 313 | | |
317 | | - | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
318 | 319 | | |
319 | 320 | | |
320 | 321 | | |
321 | 322 | | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
322 | 328 | | |
323 | 329 | | |
324 | 330 | | |
| |||
597 | 603 | | |
598 | 604 | | |
599 | 605 | | |
600 | | - | |
| 606 | + | |
601 | 607 | | |
602 | 608 | | |
603 | 609 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
909 | 909 | | |
910 | 910 | | |
911 | 911 | | |
| 912 | + | |
| 913 | + | |
| 914 | + | |
| 915 | + | |
| 916 | + | |
| 917 | + | |
| 918 | + | |
| 919 | + | |
| 920 | + | |
| 921 | + | |
912 | 922 | | |
913 | 923 | | |
914 | 924 | | |
| |||
0 commit comments