rcmdnk / homebrew-file

Brewfile manager for Homebrew
http://homebrew-file.readthedocs.io/
MIT License
356 stars 29 forks source link

TypeAlias at python3.8 and python3.9 #161

Open rcmdnk opened 1 year ago

rcmdnk commented 1 year ago

Python3.8 does not allow alias with dict, list, tuple even with from __future__ import annotations

from __future__ import annotations

MyType = dict[str, str]

This shows an error like:

E   TypeError: 'type' object is not subscriptable

It can be written with typing.Dict (typing.List, typing.Tuple)

from __future__ import annotations

from typing import Dict

MyType = Dict[str, str]

This is OK even at python3.8.

This should be updated when python3.8 is dropped from the support.

From python3.10, typing.TypeAlias is introduced to declare aliases.

But it can not be imported by from __future__ import annotations. It can be used when only >=python3.10 is supported.