Skip to content

Conversation

@AlexWaygood
Copy link
Member

@AlexWaygood AlexWaygood commented Jan 31, 2026

The comment immediately above the f3 definition states:

# > 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).

… 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).
@AlexWaygood AlexWaygood changed the title [conformance suite] Update an assertion in historical_positional.py [conformance suite] Update an assertion in historical_positional.py to allow an optional error Jan 31, 2026


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

@srittau srittau added the topic: conformance tests Issues with the conformance test suite label Feb 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

topic: conformance tests Issues with the conformance test suite

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants