Skip to content

Conversation

@IgnaceBleukx
Copy link
Collaborator

@IgnaceBleukx IgnaceBleukx commented Oct 13, 2025

Start of typehinting implementation.

Currently stuck on defining the "is_any_list" type, mypy is complaining about a lot it seems...
Something that's quite annoying is that we have explicit checks for which type a certain argument has (e.g., is_bool or is_num), but mypy of course has no idea these functions check what they say they check... so it complains even tho we know it is correct (there are "ignore" tags but they seem cumbersome)

@IgnaceBleukx IgnaceBleukx marked this pull request as draft October 13, 2025 22:02
@ThomSerg
Copy link
Collaborator

Using typing.cast we can give the required info to the static type checker. I included some small examples.
https://peps.python.org/pep-0484/#casts
It is an "empty function", so it will have a very very small performance impact.

Additionally, a lot of the code requires the args_list to be an "indexable", which Collection is not. The Sequence type would fix this (e.g. NestedList = Sequence[Union[T, "NestedList[T]"]]), but I believe this wouldn't allow for passing iterators. But doesn't seem to be a problem here, since we consume the iterator during construction (in the Expression.__init__).

In general I quite like this start.

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.

3 participants