Skip to content

Conversation

@richardpaulhudson
Copy link
Contributor

@richardpaulhudson richardpaulhudson commented Feb 24, 2022

  • Make it possible to declare layer model types e.g. Model[A, K] where the model supports types Model[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.

@richardpaulhudson richardpaulhudson marked this pull request as ready for review February 24, 2022 18:32
@svlandeg svlandeg self-requested a review February 25, 2022 09:15
@@ -1,34 +1,34 @@
from typing import Tuple, Callable, Sequence, Any, List, TypeVar
from typing import Tuple, Callable, Sequence, Any, List, TypeVar, Optional
Copy link
Contributor Author

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?

Copy link
Contributor

@svlandeg svlandeg left a 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.

Copy link
Contributor

@svlandeg svlandeg left a 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.

@svlandeg
Copy link
Contributor

Before we'd merge this in, we'd also need to re-test spacy against the current version in this PR.

@richardpaulhudson richardpaulhudson changed the base branch from master to develop May 3, 2022 12:18
@svlandeg svlandeg self-requested a review May 4, 2022 09:52
Copy link
Contributor

@svlandeg svlandeg left a 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! 😁

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Feature requests and improvements feat / types Type hints and type checking

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants