python / mypy

Optional static typing for Python
https://www.mypy-lang.org/
Other
18.19k stars 2.78k forks source link

Plugin api named_type() is ambiguous and inconsistent and broken #6578

Open gvanrossum opened 5 years ago

gvanrossum commented 5 years ago

The plugin API defines two different interfaces (TypeAnalyzerPluginInterface and SemanticAnalyzerPluginInterface) that each define a method named_type(). These look almost identical, but looks are deceptive.

First, the specified signatures differ subtly:

Second, the implementations differ:

Third, the type checker's named_type() implementation doesn't actually take a list of type arguments at all -- it's a method with only one argument, the name to look up. It always fills in all type parameters with Any. (It looks like the method we want here is named_generic_type().)

Fourth, apparently mypy's own type checking doesn't catch the discrepancy between the implemented spec (only a name) and the interface spec (name + args).

ilevkivskyi commented 5 years ago

This is related to https://github.com/python/mypy/issues/4157. We are going to fix this after we are done with the main part of the refactoring (i.e. soon).

ilevkivskyi commented 5 years ago

Fourth, apparently mypy's own type checking doesn't catch the discrepancy between the implemented spec (only a name) and the interface spec (name + args).

This is a separate problem I think. @Michael0x2a do we already have an issue for this?

plankthom commented 2 years ago

FYI: sqlmypy is hit by this api change: https://github.com/dropbox/sqlalchemy-stubs/issues/232