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
8 changes: 7 additions & 1 deletion stdlib/marshal.pyi
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
import builtins
import sys
import types
from _typeshed import ReadableBuffer, SupportsRead, SupportsWrite
from typing import Any, Final, TypeAlias

version: Final[int]

if sys.version_info >= (3, 15):
_MarshallableMapping: TypeAlias = dict[Any, Any] | builtins.frozendict[Any, Any]
else:
_MarshallableMapping: TypeAlias = dict[Any, Any]

_Marshallable: TypeAlias = (
# handled in w_complex_object() in marshal.c
int
Expand All @@ -14,7 +20,7 @@ _Marshallable: TypeAlias = (
| str
| tuple[_Marshallable, ...]
| list[Any]
| dict[Any, Any]
| _MarshallableMapping
| set[Any]
| frozenset[_Marshallable]
| types.CodeType
Expand Down
7 changes: 6 additions & 1 deletion stdlib/xml/etree/ElementTree.pyi
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import builtins

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.

Same question as before: Do we need to import builtins?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The import is there for Ruff. I tried using plain frozendict in both 3.15 branches. Ruff 0.16.10 flags it as an undefined name in both Element.__init__ and the marshal type alias under the repository’s configuration. Both files pass with builtins.frozendict. Python 3.15 itself can resolve the name directly.

import sys
from _collections_abc import dict_keys
from _typeshed import FileDescriptorOrPath, ReadableBuffer, SupportsRead, SupportsWrite
Expand Down Expand Up @@ -92,7 +93,11 @@ class Element(Generic[_Tag]):
attrib: dict[str, str]
text: str | None
tail: str | None
def __init__(self, tag: _Tag, attrib: dict[str, str] = {}, **extra: str) -> None: ...
if sys.version_info >= (3, 15):
def __init__(self, tag: _Tag, attrib: dict[str, str] | builtins.frozendict[str, str] = {}, **extra: str) -> None: ...
else:
def __init__(self, tag: _Tag, attrib: dict[str, str] = {}, **extra: str) -> None: ...

def append(self, subelement: Element[Any], /) -> None: ...
def clear(self) -> None: ...
def extend(self, elements: Iterable[Element[Any]], /) -> None: ...
Expand Down
Loading