pytype icon indicating copy to clipboard operation
pytype copied to clipboard

False-positive name-error when using `@dataclass` decorator

Open cebtenzzre opened this issue 7 months ago • 1 comments

Software versions

Python 3.11.3 pytype 2023.12.08

Testcase

from dataclasses import dataclass

class VocabLoader:
    def __init__(self):
        find_vocab_file_path()

@dataclass
class ModelPlus:
    vocab: VocabLoader

def find_vocab_file_path():
    pass

Description

$ pytype-single repr.py
File "repr.py", line 5, in __init__: Name 'find_vocab_file_path' is not defined [name-error]
Called from (traceback):
  line 7, in current file

For more details, see https://google.github.io/pytype/errors.html#name-error

cebtenzzre avatar Dec 13 '23 18:12 cebtenzzre