-
Notifications
You must be signed in to change notification settings - Fork 287
Add bound types throughout layers and Ops #599
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add bound types throughout layers and Ops #599
Conversation
thinc/layers/with_flatten.py
Outdated
| @@ -1,34 +1,34 @@ | |||
| from typing import Tuple, Callable, Sequence, Any, List, TypeVar | |||
| from typing import Tuple, Callable, Sequence, Any, List, TypeVar, Optional | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've remodelled this along the lines of e.g. with_array; is that correct?
svlandeg
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another batch of reviews - I'll pause for a bit so we can decide/iterate on the ListXd thing from my last comment first.
svlandeg
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It feels like we're close to wrapping this one up! Added some more review comments.
|
Before we'd merge this in, we'd also need to re-test |
svlandeg
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has been quite the epic PR! I'm really happy that the Thinc types have gotten so much love and attention and are now in much better shape. Thanks for following through on this PR to the bitter end, Richard! 😁
Make it possible to declare layer model types e.g.
Model[A, K]where the model supports typesModel[Union[A, B, C], Union[K, L, M]]. This relies on bound type variables as defined in PEP484.This should hopefully make Thinc typing more developer-friendly and also increase the effectiveness of the Mypy Thinc plugin checking the validity of model chains, because it allows the specification of the concrete types being used in a given situation.
Note that most of the type the documented type remains the same: covariant types are defined and used in the context of individual modules.
Support Mypy version 0.942 and Pydantic version 1.9.0.
Correct the documented type for some functions where it did not reflect the functionality supported by the code.
Cross-check the documentation with the code with respect to typing.
Despite the size of this PR, it changes virtually no running code: almost all the changes are to type definitions.
Btw I have now noticed #566 and this PR seems to have covered everything that is changed there.