Skip to content

_granian.pyi stub file missing return types for None #752

@oliverlambson

Description

@oliverlambson

If a function returns None, it should be explicitly annotated as-such for code to be fully-typed. According to PEP-484 if no return type is provided, Any should be assumed. Some type checkers allow enabling leniency for this, but in strict mode do not allow it.

Relevant extracts from PEP 484 "the meaning of annotations":

For a checked function, the default annotation for arguments and for the return type is Any.

Note that the return type of __init__ ought to be annotated with -> None. The reason for this is subtle. If __init__ assumed a return annotation of -> None, would that mean that an argument-less, un-annotated __init__ method should still be type-checked? Rather than leaving this ambiguous or introducing an exception to the exception, we simply say that __init__ ought to have a return annotation; the default behavior is thus the same as for other methods.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions