Add bound types throughout layers and Ops#599
Merged
svlandeg merged 79 commits intoexplosion:developfrom May 9, 2022
Merged
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 | |||
Contributor
Author
There was a problem hiding this comment.
I've remodelled this along the lines of e.g. with_array; is that correct?
3 tasks
svlandeg
reviewed
Apr 14, 2022
Contributor
svlandeg
left a comment
There was a problem hiding this comment.
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
reviewed
Apr 28, 2022
Contributor
svlandeg
left a comment
There was a problem hiding this comment.
It feels like we're close to wrapping this one up! Added some more review comments.
Contributor
|
Before we'd merge this in, we'd also need to re-test |
svlandeg
reviewed
May 2, 2022
3 tasks
danieldk
approved these changes
May 4, 2022
svlandeg
reviewed
May 6, 2022
svlandeg
approved these changes
May 9, 2022
Contributor
svlandeg
left a comment
There was a problem hiding this comment.
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! 😁
3 tasks
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.