Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Propagate reads on global variables #11584

Merged
merged 1 commit into from
May 28, 2024
Merged

Propagate reads on global variables #11584

merged 1 commit into from
May 28, 2024

Conversation

charliermarsh
Copy link
Member

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:

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:

from app import redis_connection

def func():
    global redis_connection

    redis_connection()

Closes #11518.

@charliermarsh charliermarsh added the bug Something isn't working label May 28, 2024
Copy link
Contributor

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

@charliermarsh charliermarsh merged commit 69d9212 into main May 28, 2024
19 checks passed
@charliermarsh charliermarsh deleted the charlie/global branch May 28, 2024 18:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ruff is removing used imports
1 participant