GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — Spec/Conformance: subtyping callables with non-constant parameter mapping. · Issue #2224 · python/typing Open Labels topic: typing specFor improving the typing specFor improving the typing spec DescriptionConsider the example below, which errors with all tested type checkers (mypy/pyright/ty/pyrefly): 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 # ❌️ type checkers error here. I believe from a pure type theory POV, this assignment should be legal, because all legal arguments to
And I couldn't find anything else in https://typing.python.org/en/latest/spec/callables.html#assignability-rules-for-callables that would disallow this assignment. It seems the type-checkers try to match the
and all these 3 call signatures are supported by
So either the spec should demand a constant parameter mapping, or this example should be added to the conformance tests. Activity
MetadataMetadataAssigneesLabelstopic: typing specFor improving the typing specFor improving the typing spec ProjectsMilestoneRelationshipsDevelopmentIssue actions |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |