Skip to content

Idea: allow description of type-effect for functions that return bool #2357

Closed
@elazarg

Description

@elazarg

I often encounter situations where I would like to extract some test into a function, but then mypy will not understand the implication on the types of the arguments. This goes against the intention that type checking will guide the programmer towards writing more readable code.

Similar case is functions like callable as in #1973, which requires hard coding so that mypy will understand.

I suggest a @type_effect decorator, possibly something along these lines:

@type_effect(true='x <: Callable')
def callable(x: object) -> bool: ...

Although the syntax is of secondary in this case.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions