Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions conformance/tests/callables_non_constant_mapping.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
"""
Tests callable assignability with non-constant parameter mapping.

Specification: https://typing.readthedocs.io/en/latest/spec/callables.html#assignability-rules-for-callables

This case is currently rejected by type checkers but appears to be
allowed by the typing spec, since all valid calls are accepted.
"""

from typing import Protocol


class Interval: ...


class Make(Protocol):
def __call__(self, /, lower: float, upper: float) -> Interval: ...


def make_impl(
string_or_lower: str | float | None = None,
/,
lower: float | None = None,
upper: float | None = None,
) -> Interval: ...


def test() -> None:
f: Make = make_impl # OK