Skip to content
Merged
Show file tree
Hide file tree
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 stdlib/builtins.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -2185,7 +2185,7 @@ if sys.version_info >= (3, 15):
class sentinel:
__name__: str
__module__: str
def __new__(cls, name: str, /) -> Self: ...
def __new__(cls, name: str, /, *, repr: str | None = None) -> Self: ...
def __copy__(self, /) -> Self: ...
def __deepcopy__(self, memo: Any, /) -> Self: ...
def __or__(self, other: Any, /) -> Any: ...
Expand Down
6 changes: 5 additions & 1 deletion stdlib/os/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -1305,7 +1305,11 @@ def mkdir(path: StrOrBytesPath, mode: int = 0o777, *, dir_fd: int | None = None)
if sys.platform != "win32":
def mkfifo(path: StrOrBytesPath, mode: int = 0o666, *, dir_fd: int | None = None) -> None: ... # Unix only

def makedirs(name: StrOrBytesPath, mode: int = 0o777, exist_ok: bool = False) -> None: ...
if sys.version_info >= (3, 15):
def makedirs(name: StrOrBytesPath, mode: int = 0o777, exist_ok: bool = False, *, parent_mode: int | None = None) -> None: ...

else:
def makedirs(name: StrOrBytesPath, mode: int = 0o777, exist_ok: bool = False) -> None: ...

if sys.platform != "win32":
def mknod(path: StrOrBytesPath, mode: int = 0o600, device: int = 0, *, dir_fd: int | None = None) -> None: ...
Expand Down
7 changes: 6 additions & 1 deletion stdlib/pathlib/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,12 @@ class Path(PurePath):
def iterdir(self) -> Generator[Self]: ...
def lchmod(self, mode: int) -> None: ...
def lstat(self) -> stat_result: ...
def mkdir(self, mode: int = 0o777, parents: bool = False, exist_ok: bool = False) -> None: ...
if sys.version_info >= (3, 15):
def mkdir(
self, mode: int = 0o777, parents: bool = False, exist_ok: bool = False, *, parent_mode: int | None = None
) -> None: ...
else:
def mkdir(self, mode: int = 0o777, parents: bool = False, exist_ok: bool = False) -> None: ...

if sys.version_info >= (3, 14):
@property
Expand Down
24 changes: 16 additions & 8 deletions stdlib/pprint.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ from typing import IO
__all__ = ["pprint", "pformat", "isreadable", "isrecursive", "saferepr", "PrettyPrinter", "pp"]

if sys.version_info >= (3, 15):
# The `expand` parameter was added in Python 3.15.
def pformat(
object: object,
indent: int = 4,
width: int = 88,
indent: int = 1,
width: int = 80,
depth: int | None = None,
*,
compact: bool = False,
expand: bool = False,
sort_dicts: bool = True,
underscore_numbers: bool = False,
) -> str: ...
Expand All @@ -30,14 +32,16 @@ else:
) -> str: ...

if sys.version_info >= (3, 15):
# The `expand` parameter was added in Python 3.15.
def pp(
object: object,
stream: IO[str] | None = None,
indent: int = 4,
width: int = 88,
indent: int = 1,
width: int = 80,
depth: int | None = None,
*,
compact: bool = False,
expand: bool = False,
sort_dicts: bool = False,
underscore_numbers: bool = False,
) -> None: ...
Expand All @@ -56,14 +60,16 @@ else:
) -> None: ...

if sys.version_info >= (3, 15):
# The `expand` parameter was added in Python 3.15.
def pprint(
object: object,
stream: IO[str] | None = None,
indent: int = 4,
width: int = 88,
indent: int = 1,
width: int = 80,
depth: int | None = None,
*,
compact: bool = False,
expand: bool = False,
sort_dicts: bool = True,
underscore_numbers: bool = False,
) -> None: ...
Expand All @@ -87,14 +93,16 @@ def saferepr(object: object) -> str: ...

class PrettyPrinter:
if sys.version_info >= (3, 15):
# The `expand` parameter was added in Python 3.15.
def __init__(
self,
indent: int = 4,
width: int = 88,
indent: int = 1,
width: int = 80,
depth: int | None = None,
stream: IO[str] | None = None,
*,
compact: bool = False,
expand: bool = False,
sort_dicts: bool = True,
underscore_numbers: bool = False,
) -> None: ...
Expand Down
3 changes: 2 additions & 1 deletion stdlib/profiling/sampling/collector.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from _typeshed import StrOrBytesPath
from abc import ABC, abstractmethod
from collections.abc import Sequence
from typing import TypeAlias
from typing import ClassVar, TypeAlias

from _remote_debugging import AwaitedInfo, FrameInfo, InterpreterInfo, LocationInfo

Expand All @@ -15,6 +15,7 @@ def filter_internal_frames(frames: Sequence[_Frame]) -> list[_Frame]: ...
def iter_async_frames(awaited_info_list: Sequence[AwaitedInfo]) -> object: ...

class Collector(ABC):
aggregating: ClassVar[bool] # undocumented
@abstractmethod
def collect(
self, stack_frames: Sequence[InterpreterInfo] | Sequence[AwaitedInfo], timestamps_us: _Timestamps = None
Expand Down
27 changes: 11 additions & 16 deletions stdlib/site.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,17 @@ def abs_paths() -> None: ... # undocumented
def addpackage(sitedir: StrPath, name: StrPath, known_paths: set[str] | None) -> set[str] | None: ... # undocumented

if sys.version_info >= (3, 15):
def process_startup_files() -> None: ... # undocumented
def addsitedir(sitedir: str, known_paths: set[str] | None = None, *, defer_processing_start_files: bool = False) -> None: ...
def addsitepackages(
known_paths: set[str] | None, prefixes: Iterable[str] | None = None, *, defer_processing_start_files: bool = False
) -> set[str] | None: ... # undocumented
def addusersitepackages(
known_paths: set[str] | None, *, defer_processing_start_files: bool = False
) -> set[str] | None: ... # undocumented

else:
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

class StartupState:
Comment thread
AlexWaygood marked this conversation as resolved.
__slots__ = ("_known_paths", "_processed_sitedirs", "_path_entries", "_importexecs", "_entrypoints")
def __init__(self, known_paths: set[str] | None = None) -> None: ...
def addsitedir(self, sitedir: str) -> None: ...
def addusersitepackages(self) -> None: ...
def addsitepackages(self, prefixes: Iterable[str] | None = None) -> None: ...
def process(self) -> None: ...

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
Comment on lines +24 to +25
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

Comment on lines +23 to +25
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(): ...

def check_enableusersite() -> bool | None: ... # undocumented

if sys.version_info >= (3, 13):
Expand Down
2 changes: 1 addition & 1 deletion stdlib/sys/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ maxunicode: int
meta_path: list[MetaPathFinderProtocol]
modules: dict[str, ModuleType]
if sys.version_info >= (3, 15):
lazy_modules: dict[str, set[str]]
lazy_modules: set[str]
orig_argv: list[str]
path: list[str]
path_hooks: list[Callable[[str], PathEntryFinderProtocol]]
Expand Down
Loading