Skip to content

Conversation

nuclearsandwich
Copy link
Contributor

_ansi is not currently used as a global (it is a module variable in this file only and flake8 now catches and lints this unneeded declaration.

_ansi is not currently used as a global (it is a module variable in this
file only and flake8 now catches and lints this unneeded declaration.
The flake8 global complaint () has previously caught cases where the
global declaration was unecessary. In this case, a test started failing
after the change and I'm struggling to understand how the previous
behavior was working properly since as far as I can tell it does
overwrite the global rather than update it.

def enable_ANSI_colors():
"""Populate the global module dictionary `ansi` with ANSI escape sequences."""
global _ansi
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is in the commit history now but as it happens this usage was not spurious nor flagged by flake8 but I assumed that 2/3 == 3/3 and removed it anyway. In order to fix the failing test without restoring the use of the global declaration I changed the code to update rather than assign and I think it's cleaner.

@nuclearsandwich nuclearsandwich merged commit a581ace into master Jul 7, 2025
17 checks passed
@cottsay cottsay deleted the flake8-global branch July 7, 2025 23:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants