Skip to content

Fix 3.15 stdlib stubtest#15863

Merged
srittau merged 3 commits into
mainfrom
fix-daily-stubtest-2026-06-04
Jun 4, 2026
Merged

Fix 3.15 stdlib stubtest#15863
srittau merged 3 commits into
mainfrom
fix-daily-stubtest-2026-06-04

Conversation

@AlexWaygood
Copy link
Copy Markdown
Member

@AlexWaygood AlexWaygood commented Jun 4, 2026

Helps with #15861 (but there's some third-party stubtest failures too)

@github-actions

This comment has been minimized.

@AlexWaygood AlexWaygood marked this pull request as ready for review June 4, 2026 12:22
Comment thread stdlib/site.pyi
Comment thread stdlib/site.pyi
Comment on lines +23 to +24
def addsitepackages(known_paths: set[str] | None, prefixes: Iterable[str] | None = None) -> set[str] | None: ... # undocumented
def addusersitepackages(known_paths: set[str] | None) -> set[str] | None: ... # undocumented
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Should this really allow a known_paths argument to be None? From the way it's supposed to be used that doesn't make too much sense to me.

Suggested change
def addsitepackages(known_paths: set[str] | None, prefixes: Iterable[str] | None = None) -> set[str] | None: ... # undocumented
def addusersitepackages(known_paths: set[str] | None) -> set[str] | None: ... # undocumented
def addsitepackages(known_paths: set[str], prefixes: Iterable[str] | None = None) -> set[str]: ... # undocumented
def addusersitepackages(known_paths: set[str]) -> set[str]: ... # undocumented

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Hmm, this just matches the previous annotations here. I haven't changed the types of any of these parameters in this PR. I'm open to changing them, but I think it's outside the scope of this PR

Copy link
Copy Markdown
Collaborator

@srittau srittau Jun 4, 2026

Choose a reason for hiding this comment

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

Oh, I think the lines are marked as "changed", since the indentation (for the >= (3, 15) block) got lost. Can you check that, it's always a bit hard to see in GitHub diffs.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Previous patch releases of 3.15 added a defer_processing_start_files: bool = False parameter to these three functions, which meant that we had to have two branches: one if sys.version_info >= (3, 15) branch, and an else branch for earlier definitions that didn't have the new parameter. That parameter addition has now been reverted; the definition is now the same on 3.15 as it was on earlier Python versions. So this PR collapses the two sys.version_info branches into one block at the module level for addsitedir, addsitepackages and addusersitepackages. That's why these lines show up as "changed" in the GitHub diff. The functions have exactly the same signature that they had previously in the Python <3.15 branch

Co-authored-by: Sebastian Rittau <sebastian.rittau@zfutura.de>
@AlexWaygood AlexWaygood requested a review from srittau June 4, 2026 12:38
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 4, 2026

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

Comment thread stdlib/site.pyi
Comment on lines +23 to +25
def addsitedir(sitedir: str, known_paths: set[str] | None = None) -> None: ...
def addsitepackages(known_paths: set[str] | None, prefixes: Iterable[str] | None = None) -> set[str] | None: ... # undocumented
def addusersitepackages(known_paths: set[str] | None) -> set[str] | None: ... # undocumented
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I assume this was a mistake?

Suggested change
def addsitedir(sitedir: str, known_paths: set[str] | None = None) -> None: ...
def addsitepackages(known_paths: set[str] | None, prefixes: Iterable[str] | None = None) -> set[str] | None: ... # undocumented
def addusersitepackages(known_paths: set[str] | None) -> set[str] | None: ... # undocumented
def addsitedir(sitedir: str, known_paths: set[str] | None = None) -> None: ...
def addsitepackages(known_paths: set[str] | None, prefixes: Iterable[str] | None = None) -> set[str] | None: ... # undocumented
def addusersitepackages(known_paths: set[str] | None) -> set[str] | None: ... # undocumented

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

no, not a mistake -- see my reply at #15863 (comment). We don't need split definitions over two sys.version_info branches anymore

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Hmm, they exist on 3.14, but why were they indented before? Maybe we should move the whole problem with these functions to another PR altogether.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Again, I explained this in #15863 (comment). We previously had this:

if sys.version_info >= (3, 15):
    def addsitedir(new_parameter): ...
else:
    def addsitedir(): ...

but the addition of the new parameter in 3.15 was reverted, so now we just have this again, removing the indentation that was previously necessary:

def addsitedir(): ...

@srittau srittau merged commit 0ffff97 into main Jun 4, 2026
58 checks passed
@srittau srittau deleted the fix-daily-stubtest-2026-06-04 branch June 4, 2026 12:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants