Skip to content

Using Python type hints #2550

@jpchen

Description

@jpchen

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

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions