-
-
Notifications
You must be signed in to change notification settings - Fork 34k
Open
Labels
stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-XMLtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Bug report
Bug description:
This code runs fine on Python 3.13.7:
import xml.etree.ElementTree as ET
x = ET.Element("x")
ET.SubElement(x, 0, parent="0")However, Pyright correctly detects a type error in the SubElement call. SubElement has this Python signature:
def SubElement(parent, tag, attrib={}, **extra):The parent parameter has already been assigned, so this should fail. I believe the fact that it doesn't is because it's actually using a C implementation, and the C implementation has this type signature:
def SubElement(parent, tag, /, attrib={}, **extra):
Which does allow specifying parent="0".
So I think the solution is just to add that / into the Python code.
CPython versions tested on:
3.13
Operating systems tested on:
Linux
Metadata
Metadata
Assignees
Labels
stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-XMLtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error