google / pytype

A static type analyzer for Python code
https://google.github.io/pytype
Other
4.71k stars 274 forks source link

"pytype.pytd.visitors.ContainerError: Conflicting values for TypeVar" when parsing SQLAlchemy stubs created by stubgen #1087

Open rchen152 opened 2 years ago

rchen152 commented 2 years ago

See https://github.com/python/typeshed/pull/6585. There are two problems:

rchen152 commented 2 years ago

Update: we're also getting some odd error in involving sqlalchemy.types (https://github.com/google/pytype/issues/1240):

Couldn't import pyi for 'sqlalchemy.dialects.postgresql' [pyi-error] Can't find pyi for 'sqltypes.ARRAY', referenced from 'sqlalchemy.dialects.postgresql.array'

The sqlalchemy.dialects.postgresql.array stub contains:

import sqlalchemy.types as sqltypes
[...]
class ARRAY(sqltypes.ARRAY): ...

which is what I assume pytype is unhappy about. When I try running pytype over all the sqlalchemy stubs, I see lots of errors like this involving various sqlalchemy.types attributes.

rchen152 commented 1 year ago

Most of the pytype errors in the SQLAlchemy stubs have been fixed; two files are still on the exclude list due to a "conflicting values for TypeVar" error: https://github.com/python/typeshed/blob/2ec6ba979f98c3c49d3a7ac2b11f1b3459e8e95a/tests/pytype_exclude_list.txt#L18-L19.