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.
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 fromdataspec.Spec.conform
(and thus the type accepted bydataspec.Spec.conform_valid
). These don't work in all cases and I had to dump out toAny
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.