Skip to content

Type annotations#460

Open
dimbleby wants to merge 6 commits intopython-poetry:masterfrom
dimbleby:type-annotations
Open

Type annotations#460
dimbleby wants to merge 6 commits intopython-poetry:masterfrom
dimbleby:type-annotations

Conversation

@dimbleby
Copy link

@dimbleby dimbleby commented Mar 22, 2026

Fixes #326, hopefully.

I have let our AI friends loose on fixing the type annotations in this project, so that we now have:

$ mypy --strict tomlkit tests/
Success: no issues found in 26 source files

I am aware that this is quite a large pull request - sorry about that - but there was quite a lot to fix.

In general the strategy has been: when returning a value whose type cannot possibly be known ahead of time (eg foo["bar"], then Any is fine. But where it is possible to give more precise types, prefer to do that.

That the tests are clean and have to # type: ignore almost nothing is good evidence that the types are now usable. I also tried pointing poetry at this version of tomlkit - it cleaned up a handful of ignore, allowed removal of some undesirable cast(), and did not break anything.

@dimbleby dimbleby force-pushed the type-annotations branch 3 times, most recently from 5b50699 to 9250374 Compare March 22, 2026 19:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MyPy errors when using tomlkit to modify toml documents

1 participant