pytype icon indicating copy to clipboard operation
pytype copied to clipboard

pytype fails to import attrs.AttrsInstance

Open bbenne10 opened this issue 2 years ago • 1 comments

In attempting to use AttrsInstance to type a (admittedly very general) interface to a new library, I find that I cannot get pytype to find the type without also importing define.

Reproduction case (Note this is the ONLY thing in the file):

from attrs import AttrsInstance

Oddly, this does not reproduce the problem:

from attrs import define, AttrsInstance

I honestly have no idea why this is happening. Insights welcome :)

bbenne10 avatar Aug 10 '23 20:08 bbenne10

I don't think define is related to this issue, it's simply that #1571 was hiding the bug when define was also imported.

$ cat repro.py
from attrs import AttrsInstance, define
$ pytype-single repro.py
File "repro.py", line 1, in <module>: Can't find module 'attrs.AttrsInstance'. [import-error]

For more details, see https://google.github.io/pytype/errors.html#import-error
$ python repro.py
$

gmacon avatar Feb 14 '24 20:02 gmacon