Current Devel Branch Fails To Start Using Python 3.9

41 views
Skip to first unread message

Thomas Passin

unread,
Apr 24, 2024, 10:30:50 AM4/24/24
to leo-editor
py -3.9 -m leo.core.runLeo
... 
   from leo.core import leoVim
  File "C:\Tom\git\leo-editor\leo\core\leoVim.py", line 25, in <module>
    from typing import Any, TypeAlias, TYPE_CHECKING
ImportError: cannot import name 'TypeAlias' from 'typing' (C:\Program Files\Python39\lib\typing.py)


This changeset does run using Python 3.10 and up.

Edward K. Ream

unread,
Apr 24, 2024, 11:02:34 AM4/24/24
to leo-e...@googlegroups.com
Thanks for this report, Thomas.  See #3884. I'll fix this immediately.

Edward

Thomas Passin

unread,
Apr 24, 2024, 11:52:40 AM4/24/24
to leo-editor
Lucky I've still got Python 3.9 on my machine!

Edward K. Ream

unread,
Apr 24, 2024, 12:33:19 PM4/24/24
to leo-editor
On Wednesday, April 24, 2024 at 10:02:34 AM UTC-5 Edward K. Ream wrote:

Thanks for this report, Thomas.  See #3884. I'll fix this immediately.

PR #3885 contains an elegant fix.

The PR moves from typing import TypeAlias into the range of if TYPE_CHECKING:

This change works because TYPE_CHECKING is always False at runtime. Even if the import fails, only mypy will be affected. At worst, mypy's type checking will be degraded for the five affected files.

Tests show that Leo loads with Python 3.9 :-)

Edward

Edward K. Ream

unread,
Apr 25, 2024, 6:04:49 AM4/25/24
to leo-editor
On Wednesday, April 24, 2024 at 11:33:19 AM UTC-5 Edward K. Ream wrote:

> PR #3885 ...moves from typing import TypeAlias into the range of if TYPE_CHECKING:
...
> Even if the import fails, only mypy will be affected. At worst, mypy's type checking will be degraded for the five affected files.

I forgot to mention the crucial point: mypy must pass only on Python 3.12.

I tolerate (expect!) mypy complaints on earlier versions of Python!

Edward
Reply all
Reply to author
Forward
0 new messages