-
-
Notifications
You must be signed in to change notification settings - Fork 996
Open
Description
Since Pyro supports exclusively Python 3, we should look into adding type hints. This has a few advantages:
- pep8 linters can check for type errors
- easier for a reader to understand function signatures. useful for eg funsor where multiple dispatching is prevalent.
- sphinx docs can autogenerate types of args
- IDE static analysis tools will work (better)
e.g.
from typing import List, Optional
def foo(bar: List, baz: Optional[List] = None) -> List:
return bar
Add type hints to modules
- contrib
- distributions
- distributions.transforms
- distributions.constraints
- infer
- nn
- ops
- optim Type Hints for Optim module and Setup MyPy as part of CI #2853
- params Add
param_store.py
type hints #3271 - poutine
- Annotate handlers & add py.typed #3321
- Mypy
warn_unreachable=True
#3312 - Type annotate messengers #3309
- Type annotate messengers #3308
- Type annotate poutines #3306
- Type annotate
Trace
,TraceMessenger
, &pyro.poutine.guide
#3299 - Type annotate broadcast, condition, do, enum messengers #3295
- Type annotate
pyro.primitives
&poutine.block_messenger
#3292 - Type annotate
pyro.poutine.messenger
#3290 - Type annotate
pyro.poutine.runtime
#3288
- scripts
- tests.test_primitives
- tests.test_generic (low priority)
- tests.poutine
- tests.ops
- tests.optim
- tests.perf
- tests.nn
- tests.infer
- tests.distributions
- tests.contrib
Additional functionality for type hints
- Give warnings on #type ignore in codebase
Grey might be a good idea for finding #type ignores - Give warnings on modules skipped by mypy
fritzo, Sayam753, tuchandra, ciguaran, akihironitta and 2 more