-
Notifications
You must be signed in to change notification settings - Fork 627
Labels
enhancementit's not broken, but we want it to be betterit's not broken, but we want it to be bettermetafor wider topics than the software itselffor wider topics than the software itself
Description
The new typing module in 3.5 and PEP 0484 add static type annotations to Python. It would be nice for the Hypothesis API to support this, as the public API is actually pretty static in nature. stub files offer a compatibility mode, so this can be done transparently without dropping support for Python 2 (which is sadly there for the long haul).
Steps this would require:
- Making Strategy a generic type with a single parameter, Strategy[T] that specifies the type of value generated. Note that Strategy is covariant in its type parameter.
- Providing static types for all of the public API in hypothesis and hypothesis.strategies.
- Running a mypy checker on Hypothesis + its test suite as part of the build
Things to note:
givenandbuildscannot be precisely typed with this type system, but they can still have types that are better than nothing by constraining their *args and **kwargs to have a strategy type (this is actually quite useful because it will catch two common gotchas when using this).- Settings is going to be quite hard to type correctly and is probably not worth bothering with.
- I am not proposing to make Hypothesis internals typed. In particular templates for strategies will remain completely untyped. I've worked out what typing this accurately requires in the past and PEP 0484 can't begin to express it.
mmuggli, Daenyth, maxnordlund, lycantropos and Zac-HD
Metadata
Metadata
Assignees
Labels
enhancementit's not broken, but we want it to be betterit's not broken, but we want it to be bettermetafor wider topics than the software itselffor wider topics than the software itself