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
2 changes: 1 addition & 1 deletion conformance/tests/historical_positional.py
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Copy link
Contributor

@sinon sinon Jan 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Can you call f3 with x as a keyword argument though? Won't you get SyntaxError: positional argument follows keyword argument? So is it maybe the case that you can't actually use x as keyword argument based on that constraint from it's positioning before positional arguments.

# > Consistent with PEP 570 syntax, positional-only parameters cannot appear
# > after parameters that accept keyword arguments. Type checkers should
# > enforce this requirement:

So this then does apply?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can call f3 with x as a keyword argument; you just can't do it while also providing any additional *args:

>>> def f3(x: int, *args: int, __y: int) -> None: ...
>>> f3(x=1, __y=2)

Copy link
Member Author

@AlexWaygood AlexWaygood Jan 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I should probably add a comment above the definition of f3 clarifying this, since it's admittedly a little subtle



f3(3, __y=3) # OK
Expand Down