Skip to content
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

Improve type annotations #69

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft

Conversation

chrisrink10
Copy link
Contributor

This is an experimental PR to try to improve the quality and precision of type annotations on builtin base types and factories. In its current form, I've added two generic parameters to the dataspec.Spec interface. The first parameter indicates the valid input type and the second is the expected return type from dataspec.Spec.conform (and thus the type accepted by dataspec.Spec.conform_valid). These don't work in all cases and I had to dump out to Any in several instances. Furthermore, primarily dynamic operations like composing multiple conformers procedurally cannot be sufficiently expressed using MyPy's existing generic facilities (or, at least, I don't know how to do it).

The other major addition is multiple overloaded signatures for classmethod constructors (and soon, for make_spec/s) which will probably allow MyPy to check types much more richly than before.

I'm leaving this in a draft state now and I'll continue to work on it as I have time.

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

Successfully merging this pull request may close these issues.

1 participant