Skip to content

Tracking ty compatibility#4168

Draft
behrmann wants to merge 1 commit into
systemd:mainfrom
behrmann:typymctyface
Draft

Tracking ty compatibility#4168
behrmann wants to merge 1 commit into
systemd:mainfrom
behrmann:typymctyface

Conversation

@behrmann

Copy link
Copy Markdown
Contributor

ty is a new checker from the people that brought us ruff and uv. Since it is written in Rust, it is vastly faster than mypy or pyright. It is not yet fully features, but the recent release has removed about 80% of the false positives it had before. This allows us to annotate the remaining false positives with ignore comments for ty specifically and add two type annotations that also make the intent clearer to the human reader.

At the same time, ty complains about type ignore comments, that are needed for either mypy or pyright. Unfortunately there is no syntax for type checker specific ignores, but we can silence those errors for ty. This also adds comments on which type checker makes a specific type ignore comment necessary.

Unfortunately the tests cannot yet be properly type checked with ty due to [1].

[1] astral-sh/ty#2797

Comment thread mkosi/__init__.py
@@ -5187,12 +5194,12 @@ def run_verb(args: Args, tools: Config | None, images: Sequence[Config], *, reso
if any((c := config).is_incremental() and not have_cache(config) for config in images):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can write this as a regular for loop with a check at the beginning to continue to not have to add the comments I think

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's tracked in this issue and already has a PR

Comment thread mkosi/config.py
@@ -4639,7 +4641,7 @@ def resolve_deps(images: Sequence[Config], include: Sequence[str]) -> list[Confi
graph = {config.image: config.dependencies for config in images}

if any((missing := i) not in graph for i in include):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

@behrmann behrmann mentioned this pull request Feb 16, 2026
ty is a new checker from the people that brought us ruff and uv. Since it is
written in Rust, it is vastly faster than mypy or pyright. It is not yet fully
features, but the recent release has removed about 80% of the false positives
it had before. This allows us to annotate the remaining false positives with
ignore comments for ty specifically.

At the same time, ty complains about type ignore comments, that are needed for
either mypy or pyright. Unfortunately there is no syntax for type checker
specific ignores, but we can silence those errors for ty. This also adds
comments on which type checker makes a specific type ignore comment necessary.

Unfortunately the tests cannot yet be properly type checked with ty due to [1].

[1] astral-sh/ty#2797
@behrmann behrmann marked this pull request as draft February 16, 2026 15:05
@behrmann

Copy link
Copy Markdown
Contributor Author

Drafting this now to keep this around as a tracking PR what would be needed to make mkosi check successfully with ty. This should be merged as is, since ty should learn the things that are currently missing and adding the ignores here could silence them in their CI, which also checks mkosi.

@behrmann behrmann changed the title Add ty ignore comments and annotate other type ignore comments Tracking ty compatibility Feb 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants