Skip to content

The extracted method was defined outside of class scope causing 'NameError' #825

@jonh-copin

Description

@jonh-copin

The extracted method was defined outside of class scope causing 'NameError'

Steps to reproduce the behavior:

  1. Code before refactoring:
class TSV:
    """TSV format. Assumes each row is of the form `text\\tlabel`."""
    delimiter = "\t"

if __name__ == "__main__":
    print(TSV.delimiter)
  1. Apply the extract method to "\t"

  2. Code after refactoring:

class TSV:
    """TSV format. Assumes each row is of the form `text\\tlabel`."""
    delimiter = extracted_method()


def extracted_method():
    return "\t"


if __name__ == "__main__":
    print(TSV.delimiter)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugUnexpected or incorrect user-visible behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions