Skip to content

Conversation

cclauss
Copy link
Collaborator

@cclauss cclauss commented Sep 10, 2023

Replace import * imports in Python files with explicit imports.
% pipx run removestar --in-place . # https://www.asmeurer.com/removestar

This change allowed our linter to find and fix an undefined name: HotkeyEvent --> ControlGroupEvent

F821 undefined name 'HotkeyEvent'

This would have raised NameError at runtime.
% ruff rule F821

undefined-name (F821)

Derived from the Pyflakes linter.

What it does

Checks for uses of undefined names.

Why is this bad?

An undefined name is likely to raise NameError at runtime.

Example

def double():
    return n * 2  # raises `NameError` if `n` is undefined when `double` is called

Use instead:

def double(n):
    return n * 2

References

Copy link
Collaborator

@StoicLoofah StoicLoofah left a comment

Choose a reason for hiding this comment

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

looks good!

@StoicLoofah StoicLoofah merged commit 4d39959 into ggtracker:upstream Sep 23, 2023
@cclauss cclauss deleted the removestar branch September 23, 2023 20:58
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