rope icon indicating copy to clipboard operation
rope copied to clipboard

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

Open jonh-copin opened this issue 1 month ago • 0 comments

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)

jonh-copin avatar Nov 24 '25 19:11 jonh-copin