From 54479ee4002497ec2cefb6fc86842aaaca7c262a Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Sat, 31 Jan 2026 10:15:42 +0000 Subject: [PATCH 1/2] [conformance suite] Update an assertion in `historical_positional.py` to allow an optional error The comment immediately above the `f3` definition states: ```py # > Consistent with PEP 570 syntax, positional-only parameters cannot appear # > after parameters that accept keyword arguments. Type checkers should # > enforce this requirement: ``` But mandating that type checkers should permit the `f3` definition appears inconsistent with this comment. The `x` parameter of this function accepts keyword arguments, and comes before a parameter that uses the legacy convention for denoting positional-only parameters, so according to the portion of the spec quoted here I think type checkers *should* emit an error on it. This PR updates the line to allow an optional error to be emitted by type checkers (though I'd personally also be okay with mandating an error). --- conformance/tests/historical_positional.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conformance/tests/historical_positional.py b/conformance/tests/historical_positional.py index 4fc0aaa6a..49e3c05a4 100644 --- a/conformance/tests/historical_positional.py +++ b/conformance/tests/historical_positional.py @@ -26,7 +26,7 @@ def f1(__x: int, __y__: int = 0) -> None: ... def f2(x: int, __y: int) -> None: ... # E -def f3(x: int, *args: int, __y: int) -> None: ... # OK +def f3(x: int, *args: int, __y: int) -> None: ... # E? f3(3, __y=3) # OK From ef3f9bffb85882eec1b71b973faf48ac864668e1 Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Mon, 9 Feb 2026 13:47:11 +0000 Subject: [PATCH 2/2] add comment --- conformance/tests/historical_positional.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/conformance/tests/historical_positional.py b/conformance/tests/historical_positional.py index 49e3c05a4..915a6770b 100644 --- a/conformance/tests/historical_positional.py +++ b/conformance/tests/historical_positional.py @@ -26,6 +26,22 @@ def f1(__x: int, __y__: int = 0) -> None: ... def f2(x: int, __y: int) -> None: ... # E +# `x` is a positional-or-keyword parameter, so, +# according to a literal reading of the above rule, `__y` +# should be flagged as an error since it uses the historical +# convention for positional-only parameters but appears after +# a positional-or-keyword parameter that does not. We therefore +# permit type checkers to emit an error on this definition. +# +# Note that `x` can only be passed with a keyword argument if +# no arguments are passed positionally: +# +# ```pycon +# >>> def f3(x: int, *args: int, __y: int) -> None: ... +# ... +# >>> f3(x=1, __y=2) +# >>> +# ``` def f3(x: int, *args: int, __y: int) -> None: ... # E?