Skip to content

Reimplementation / alternative to no_globals based on static analysis #19

@dlukes

Description

@dlukes

Code objects tell you which names are global and which are local:

def foo():
    bar = 1
    baz = 2
    print(bar, baz, qux)

print(foo.__code__.co_names)
print(foo.__code__.co_varnames)
('print', 'qux')
('bar', 'baz')

Ideally, this would be an IPython extension that you enable once and then it continuously warns you whenever you create a function that refers to (non-module, non-callable -- by default, but customizable) globals.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions