Ajatt-Tools / AnkiNoteTypes

🍉 A collection of note types for Anki 2.1

Home Page:https://tatsumoto-ren.github.io/blog/join-our-community.html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Type hints break on Python 3.8

cyphar opened this issue · comments

openSUSE Tumbleweed only has Python 3.8, which causes issues due to the usage of list[str]-style type hints which were first added in Python 3.9:

Traceback (most recent call last):
  File "/usr/lib64/python3.8/runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib64/python3.8/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/home/cyphar/src/AnkiNoteTypes/antp/__main__.py", line 4, in <module>
    from antp.exporter import export_note_type
  File "/home/cyphar/src/AnkiNoteTypes/antp/exporter.py", line 10, in <module>
    import antp.common as ac
  File "/home/cyphar/src/AnkiNoteTypes/antp/common.py", line 23, in <module>
    def select(items: list[str]) -> Optional[str]:
TypeError: 'type' object is not subscriptable

I can send a patch to switch back to the old style typing.List[str] if you like.

(Actually Tumbleweed does have Python 3.9, it's just not the default and you have to install it separately.)

I'm aware of it. Thankfully, almost all platforms already have python 3.9, it was released quite a few months ago after all.