Skip to content

Propagate reads on global variables#11584

Merged
charliermarsh merged 1 commit intomainfrom
charlie/global
May 28, 2024
Merged

Propagate reads on global variables#11584
charliermarsh merged 1 commit intomainfrom
charlie/global

Conversation

@charliermarsh
Copy link
Copy Markdown
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
@github-actions
Copy link
Copy Markdown
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
@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