@electrumsv is on PowPing!

PowPing is a place where you can earn Bitcoin simply by socializing, for FREE.
Never tried Bitcoin? It's OK! Just come, socialize, and earn Bitcoin.
Check out electrumsv's activities

ElectrumSV Development

visit channel home
Total Economy: 0 USD

The Python 3.9, typing and mypy mess

ElectrumSV where possible uses the typing annotations that are provided through the typing module. This means that when we have a variable that is a list of integers we declare it as follows:

import typing
my_list: List[int] = []

As part of upcoming changes we are making the new Python 3.9 the only supported version of Python that we support. Until now, we have supported late versions of 3.7 and any version of 3.8. In 3.9 there is said to be type hinting generics, and indeed the example they give is directly applicable. This would change the variable declaration to no longer require the typing module.

my_list: list[int] = []

Here the built-in globally available list type is now supposedly usable and in theory the imported List object is no longer required. Except it just doesn't work. Maybe it works, but the type checking tool mypy says the following:

error: "list" is not subscriptable, use "Typing.List" instead.

This is sloppy. What is the point of being able to add type annotations if the way they are supposed to be used is not supported by the thing that checks them. If you believe the official releases and find out that this does not mean mypy correctly, then you can find a pinned issue on the topic on mypy's Github repository.

-- rt12

powered by powpress
link Tip