Skip to content

Add documentation about writing type annotations #4383

@maffoo

Description

@maffoo

There was a question in cirq sync today about type annotations, which makes me think we should add some documentation about how we write type annotations in cirq. Some things to address:

  • When to use a string in type annotations versus not.
  • How to use if TYPE_CHECKING.
  • When to use top-level 'cirq.Foo' annotations versus a specific import from another module.

We might also want to investigate ways to have lints on type annotations because we want to prefer top-level 'cirq.Foo' annotations but we have lots of old code that doesn't do this, and no enforcement of annotation style on new code either.

Metadata

Metadata

Assignees

Labels

area/mypykind/healthFor CI/testing/release process/refactoring/technical debt itemstriage/acceptedA consensus emerged that this bug report, feature request, or other action should be worked on

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions