Skip to content Skip to sidebar Skip to footer

Mypy Error Typevar With Value Restriction And Union Of Unions / Optional Cannot Pass Generic Container Type

So, the following example is obviously contrived but I tried to keep some verisimilitude to my actual situation. Now that I've whittled this down, I am sure I am missing something

Solution 1:

This seems to be a bug that was fixed somewhat recently in mypy. I was able to repro the problem in your first snippet by using mypy 0.630 but was unable to repro using both mypy 0.641 and the latest version of mypy on master.

I very loosely suspect the bug was fixed by https://github.com/python/mypy/pull/5699, but don't know for certain (and don't feel like checking, tbh).

You can monitor mypy's blog if you'd like to be notified of future releases to avoid similar situations in the future. New releases are made roughly every 6 weeks to two months or so. -- the next release is slated to come out in roughly two weeks or so from time of writing.

Post a Comment for "Mypy Error Typevar With Value Restriction And Union Of Unions / Optional Cannot Pass Generic Container Type"