« first day (3440 days earlier)      last day (138 days later) » 

14:54
Hello, I'm having type annotation problems again... MyPy seems to not understand ABCs for some reason? Below's a MRE:
```
import typing as tp
import numbers
T1 = tp.TypeVar("T1", bound=numbers.Integral)
a: T1 = 42 # MyPy errors here.
```
Why is this the case? Why isn't assigning `int` to a variable of bound generic type `numbers.Integral` allowed, considering `isinstance(42, numbers.Integral)` is True? Below are the error messages when testing in MyPy playground:
```
main.py:6: error: Type variable "__main__.T1" is unbound [valid-type]
Oh, and here's the playground gist link.
And with some experimenting, here's a slightly more sophisticated example, if it helps:
```
import typing as tp
import collections.abc
import numbers
T1 = tp.TypeVar("T1", bound=numbers.Integral)
err_msg = "'stop' parameter must be given an integral object, got {!r}"


def baz(stop: T1) -> collections.abc.Generator[int, None, None]:
if not isinstance(stop, numbers.Integral):
raise TypeError(err_msg.format(stop))
counter = 0
while counter < stop:
yield counter
counter += 1
```
In this case, MyPy complains on line 12 that comparing `int` with `T1` is not allowed. Artichoke??
15:25
3 messages moved from Python

« first day (3440 days earlier)      last day (138 days later) »