Open fluffy-critter opened 2 years ago
Yeah I just ran into this in my more extensive mypy testing, for some reason if I nest a similar statement in a simple function it doesn't cause mypy to flag it:
# mypy finds error with __iter__
result = select(c for c in Customer if c.country != "USA")[:]
# mypy doesn't complain at all
def asd():
result = select(c for c in Customer if c.country != "USA")[:]
I mainly use pyright on my personal projects so didn't catch this before, I figure it is because mypy also doesn't like our class Model(DbEntity)
declarations, and so as we force them through with # type: ignore
we also lose all the information of our metaclass, for example the __iter__
... I'll try to see I can come up with something, it would probably also mean cleaner model declarations which would be really nice
Ah yeah the metaclass erasure makes sense, although the trivial function wrapping fixing it doesn't make any sense at all.
It looks like one of the hairier type-inference things that Pony screws up mypy on is still happening even with this package installed. For example:
The respective lines of code are all simple generator-based queries, e.g.: