Skip to content

Conversation

@jorenham
Copy link

@jorenham jorenham commented Sep 14, 2025

This is an alternative approach to #199.

I managed to avoid importing collections.abc, types, and typing_extensions by using stringified annotations. There's no way to get around the typing import though, so a import threadpoolctl could still be slightly slower for projects that didn't already import typing.

Personally, I like this better than #199, and it's not as messy as I had expected it might be.

Compared to #199, this is also compatible with more type-checkers, namely pyright, basedpyright (a stricter pyright fork), and ty (by the same authors as ruff and uv). Mypy and the pyrights are configured in strict mode, meaning that they'll complain if they aren't able to infer some type. So that's 100% type-coverage.

I tried my best not to touch the the runtime code for as much as I could. In some cases I had to make slight adjustments, but those should not have any effect on the behavior.

@jorenham jorenham mentioned this pull request Sep 14, 2025
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.

1 participant