Cleaning up Ty type errors

24 views
Skip to first unread message

Ville M. Vainio

unread,
Aug 1, 2026, 3:13:17 PM (9 days ago) Aug 1
to leo-editor
I have a PR where I'm squashing some hundreds of type errors highlighted by Ty type checker. In case it's going to be the long term type checker instead of mypy, it makes sense to get it clean (there are good reasons for that, e.g. being very fast).

Not everything could be done by type annotations alone, as there were coding mistakes that were also uncovered in the process.

I won't have computer access for few days, but it would be good if people would be able to do some manual testing for that branch, to rule out accidental regression

Getting unit tests running in ci.yml would also be a valuable effort, I wager.

.


Ville M. Vainio

unread,
Aug 1, 2026, 3:20:55 PM (9 days ago) Aug 1
to leo-editor
In case everything is good, feel free to merge. I will create new PR's to squash the last type errors later next week

Edward K. Ream

unread,
Aug 1, 2026, 5:43:42 PM (9 days ago) Aug 1
to leo-editor
On Saturday, August 1, 2026 at 2:13:17 PM UTC-5 Ville M. Vainio wrote:

I have a PR where I'm squashing some hundreds of type errors highlighted by Ty type checker. In case it's going to be the long term type checker instead of mypy, it makes sense to get it clean (there are good reasons for that, e.g. being very fast).

Leo's full_test_leo.py script will run Ty in addition to mypy. That's possible because Ty is so fast.

Why do I want to run both Ty and mypy? Because otherwise we have an implicit switch. Speed is mostly irrelevant in GitHub actions.

Furthermore, I'll soon create an option to run Ty every time Leo writes a file, just as with flake8 and ruff format.

There is general confusion about beautifying Leo. Here are the options as found in LeoPyRef.leo:

@bool beautify-python-code-on-write = True  # Calls at.runRuffFormat. It calls c.beautify_with_ruff.
@int black-line-length = 100  # Used in c.beautify_with_ruff!
@string black-toml = None  # Used in c.beautify_with_ruff!

And here are the options in my myLeoSettings.leo:

@bool run-flake8-on-write = True  # Calls at.runFlake8

Note that leo/scripts/beautify_all_leo.py basically runs this command:

python -m ruff format --config <path to leo_editor/pyproject.toml> <list of leo directories>
 
Not everything could be done by type annotations alone, as there were coding mistakes that were also uncovered in the process.

This is a big win. Every improvement in the tool chain makes Leo stronger.

I won't have computer access for few days, but it would be good if people would be able to do some manual testing for that branch, to rule out accidental regression.

Will do. 

Getting unit tests running in ci.yml would also be a valuable effort, I wager.

I agree.

At present, I run full_test_leo.py before every push. This script runs all tests except pylint_leo.py.

I run the latter script from time to time, but I run Leo's pylint command whenever I make significant changes to a file.

Summary

We are moving towards a set of automatic checkin actions that duplicate my actual workflow. Getting to that happy state will take some time.

Edward

Edward K. Ream

unread,
Aug 1, 2026, 5:45:46 PM (9 days ago) Aug 1
to leo-e...@googlegroups.com
On Sat, Aug 1, 2026 at 2:20 PM Ville M. Vainio <viva...@gmail.com> wrote:
In case everything is good, feel free to merge.

I'll take a close look.

I will create new PR's to squash the last type errors later next week.

Many thanks for your great work.

Edward

Ville M. Vainio

unread,
Aug 4, 2026, 4:40:43 PM (6 days ago) Aug 4
to leo-editor
Regarding unit tests in ci, here's a pr for that: https://github.com/leo-editor/leo-editor/pull/4843
Reply all
Reply to author
Forward
0 new messages