ruff/crates/ruff_linter
Charlie Marsh 69d9212817
Propagate reads on global variables (#11584)
## Summary

This PR ensures that if a variable is bound via `global`, and then the
`global` is read, the originating variable is also marked as read. It's
not perfect, in that it won't detect _rebindings_, like:

```python
from app import redis_connection

def func():
    global redis_connection

    redis_connection = 1
    redis_connection()
```

So, above, `redis_connection` is still marked as unused.

But it does avoid flagging `redis_connection` as unused in:

```python
from app import redis_connection

def func():
    global redis_connection

    redis_connection()
```

Closes https://github.com/astral-sh/ruff/issues/11518.
2024-05-28 14:47:05 -04:00
..
resources Avoid recommending context manager in `__enter__` implementations (#11575) 2024-05-28 01:44:24 +00:00
src Propagate reads on global variables (#11584) 2024-05-28 14:47:05 -04:00
Cargo.toml Bump version to `v0.4.5` (#11502) 2024-05-23 01:09:01 +00:00
__init__.py [`pylint`] (Re-)Implement `import-private-name` (`C2701`) (#9553) 2024-01-16 14:03:11 -05:00