You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
del-global.py:5:9: PLW0603 Using the global statement to update `test_global_var` is discouraged
|
4 | def delete_test_global_var():
5 | global test_global_var
| ^^^^^^^^^^^^^^^ PLW0603
6 | if "test_global_var" in globals():
7 | del test_global_var
|
del-global.py:5:9: PLW0602 Using global for `test_global_var` but no assignment is done
|
4 | def delete_test_global_var():
5 | global test_global_var
| ^^^^^^^^^^^^^^^ PLW0602
6 | if "test_global_var" in globals():
7 | del test_global_var
|
Found 2 errors.
Version:
$ ruff version
ruff 0.3.2
The text was updated successfully, but these errors were encountered:
## Summary
Given `del X`, we'll typically add a `BindingKind::Deletion` to `X` to
shadow the current binding. However, if the deletion is inside of a
conditional operation, we _won't_, as in:
```python
def f():
global X
if X > 0:
del X
```
We will, however, track it as a reference to the binding. This PR adds
the expression context to those resolved references, so that we can
detect that the `X` in `global X` was "assigned to".
Closes#10397.
Sample code:
Command:
ruff check --preview --isolated --select PL del-global.py
Output:
Version:
The text was updated successfully, but these errors were encountered: