Mutating globals() dict
Detects mutations to the globals() dictionary, which can bypass type checking and lead to runtime type errors.
The globals() function returns a dictionary representing the current global symbol table. When you modify this dictionary directly, you can change the types of global variables at runtime without the type checker being aware of the change.
What gets flagged
| Python | |
|---|---|
1 2 3 4 5 6 | |
Unsoundness Checker Output
| Text Only | |
|---|---|
1 2 3 4 5 6 7 8 9 10 11 | |
Mypy: No Diagnostic Emitted
Pyright: No Diagnostic Emitted
Ty: No Diagnostic Emitted
What is okay
If the type of the new value is assignable to the existing type of the symbol, we allow the mutation.
| Python | |
|---|---|
1 2 3 4 | |
Unsoundness Checker: No Diagnostic Emitted
Mypy: No Diagnostic Emitted
Pyright: No Diagnostic Emitted
Ty: No Diagnostic Emitted