Skip to content

Strict Setting for Return Types #3013

Closed
@hmc-cs-mdrissi

Description

@hmc-cs-mdrissi

Is your feature request related to a problem? Please describe.
Can we have a config option for a library to require return type annotations? So that code like,

def f(x: int):
  return x

is an error on strict for missing return type.

Describe the solution you'd like
A configuration setting for missing return type annotations. May optionally be included in strict.

Additional context
While pyright can infer return types, I would like return type for explicitness/documentation and also to be friendly to other type checkers. Also inferred return type may be valid but not intended one by the author.

It would also make strict check vs verifytypes more similar. verifytypes rightly detects missing return types, but I'd rather not run verifytypes for every pre-commit/ci check while running pyright there is fine to me.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions