Make the optional parameters keyword-only - #45
Open
vringar wants to merge 1 commit into
Open
Conversation
vringar
force-pushed
the
ci/action-versions
branch
from
August 30, 2026 21:44
654bec0 to
01b73eb
Compare
vringar
force-pushed
the
api/keyword-only
branch
from
August 30, 2026 21:44
5c51f84 to
ddc02e5
Compare
Every parameter but the url is now keyword-only on stem_url, hostname_subparts, get_scheme and get_port. Five of them are booleans, and `stem_url(url, True, 'http', False, True)` says nothing at the call site about which of scheme, path, parse_ws or return_unparsed is which. OpenWPM, the consumer this library exists for, only ever calls get_ps_plus_1(url) with a single positional argument, and the test suite already passes everything by keyword, so nothing in reach has to change. It also makes the _StemKwargs duplication checkable. That TypedDict restates stem_url's keyword parameters so the functions forwarding **kwargs to it stay type-checked at their call sites; PEP 692 only goes from a TypedDict to **kwargs, so nothing in the language binds them together, and the pair can drift silently. With the parameters keyword-only the invariant is exact -- every keyword-only parameter, and no other, appears in the TypedDict -- and a test now asserts it by reflection.
vringar
force-pushed
the
ci/action-versions
branch
from
September 1, 2026 14:01
01b73eb to
b487104
Compare
vringar
force-pushed
the
api/keyword-only
branch
from
September 1, 2026 14:01
ddc02e5 to
46e618e
Compare
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Make the optional parameters keyword-only
Every parameter but the url is now keyword-only on stem_url,
hostname_subparts, get_scheme and get_port. Five of them are booleans, and
stem_url(url, True, 'http', False, True)says nothing at the call site aboutwhich of scheme, path, parse_ws or return_unparsed is which. OpenWPM, the
consumer this library exists for, only ever calls get_ps_plus_1(url) with a
single positional argument, and the test suite already passes everything by
keyword, so nothing in reach has to change.
It also makes the _StemKwargs duplication checkable. That TypedDict restates
stem_url's keyword parameters so the functions forwarding **kwargs to it stay
type-checked at their call sites; PEP 692 only goes from a TypedDict to
**kwargs, so nothing in the language binds them together, and the pair can
drift silently. With the parameters keyword-only the invariant is exact --
every keyword-only parameter, and no other, appears in the TypedDict -- and a
test now asserts it by reflection.