Skip to content

Commit f9e02a5

Browse files
Per feedback, make the change and avoid the overloads (builtins.pyi).
1 parent a24003d commit f9e02a5

File tree

1 file changed

+43
-89
lines changed

1 file changed

+43
-89
lines changed

stdlib/builtins.pyi

Lines changed: 43 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -1398,95 +1398,49 @@ if sys.version_info >= (3, 10):
13981398
# compile() returns a CodeType, unless the flags argument includes PyCF_ONLY_AST (=1024),
13991399
# in which case it returns ast.AST. We have overloads for flag 0 (the default) and for
14001400
# explicitly passing PyCF_ONLY_AST. We fall back to Any for other values of flags.
1401-
if sys.version_info >= (3, 12):
1402-
@overload
1403-
def compile(
1404-
source: str | ReadableBuffer | _ast.Module | _ast.Expression | _ast.Interactive,
1405-
filename: str | bytes | PathLike[Any],
1406-
mode: str,
1407-
flags: Literal[0],
1408-
dont_inherit: bool = False,
1409-
optimize: int = -1,
1410-
*,
1411-
_feature_version: int = -1,
1412-
) -> CodeType: ...
1413-
@overload
1414-
def compile(
1415-
source: str | ReadableBuffer | _ast.Module | _ast.Expression | _ast.Interactive,
1416-
filename: str | bytes | PathLike[Any],
1417-
mode: str,
1418-
*,
1419-
dont_inherit: bool = False,
1420-
optimize: int = -1,
1421-
_feature_version: int = -1,
1422-
) -> CodeType: ...
1423-
@overload
1424-
def compile(
1425-
source: str | ReadableBuffer | _ast.Module | _ast.Expression | _ast.Interactive,
1426-
filename: str | bytes | PathLike[Any],
1427-
mode: str,
1428-
flags: Literal[1024],
1429-
dont_inherit: bool = False,
1430-
optimize: int = -1,
1431-
*,
1432-
_feature_version: int = -1,
1433-
) -> _ast.AST: ...
1434-
@overload
1435-
def compile(
1436-
source: str | ReadableBuffer | _ast.Module | _ast.Expression | _ast.Interactive,
1437-
filename: str | bytes | PathLike[Any],
1438-
mode: str,
1439-
flags: int,
1440-
dont_inherit: bool = False,
1441-
optimize: int = -1,
1442-
*,
1443-
_feature_version: int = -1,
1444-
) -> Any: ...
1445-
1446-
else:
1447-
@overload
1448-
def compile(
1449-
source: str | ReadableBuffer | _ast.Module | _ast.Expression | _ast.Interactive,
1450-
filename: str | ReadableBuffer | PathLike[Any],
1451-
mode: str,
1452-
flags: Literal[0],
1453-
dont_inherit: bool = False,
1454-
optimize: int = -1,
1455-
*,
1456-
_feature_version: int = -1,
1457-
) -> CodeType: ...
1458-
@overload
1459-
def compile(
1460-
source: str | ReadableBuffer | _ast.Module | _ast.Expression | _ast.Interactive,
1461-
filename: str | ReadableBuffer | PathLike[Any],
1462-
mode: str,
1463-
*,
1464-
dont_inherit: bool = False,
1465-
optimize: int = -1,
1466-
_feature_version: int = -1,
1467-
) -> CodeType: ...
1468-
@overload
1469-
def compile(
1470-
source: str | ReadableBuffer | _ast.Module | _ast.Expression | _ast.Interactive,
1471-
filename: str | ReadableBuffer | PathLike[Any],
1472-
mode: str,
1473-
flags: Literal[1024],
1474-
dont_inherit: bool = False,
1475-
optimize: int = -1,
1476-
*,
1477-
_feature_version: int = -1,
1478-
) -> _ast.AST: ...
1479-
@overload
1480-
def compile(
1481-
source: str | ReadableBuffer | _ast.Module | _ast.Expression | _ast.Interactive,
1482-
filename: str | ReadableBuffer | PathLike[Any],
1483-
mode: str,
1484-
flags: int,
1485-
dont_inherit: bool = False,
1486-
optimize: int = -1,
1487-
*,
1488-
_feature_version: int = -1,
1489-
) -> Any: ...
1401+
@overload
1402+
def compile(
1403+
source: str | ReadableBuffer | _ast.Module | _ast.Expression | _ast.Interactive,
1404+
filename: str | bytes | PathLike[Any],
1405+
mode: str,
1406+
flags: Literal[0],
1407+
dont_inherit: bool = False,
1408+
optimize: int = -1,
1409+
*,
1410+
_feature_version: int = -1,
1411+
) -> CodeType: ...
1412+
@overload
1413+
def compile(
1414+
source: str | ReadableBuffer | _ast.Module | _ast.Expression | _ast.Interactive,
1415+
filename: str | bytes | PathLike[Any],
1416+
mode: str,
1417+
*,
1418+
dont_inherit: bool = False,
1419+
optimize: int = -1,
1420+
_feature_version: int = -1,
1421+
) -> CodeType: ...
1422+
@overload
1423+
def compile(
1424+
source: str | ReadableBuffer | _ast.Module | _ast.Expression | _ast.Interactive,
1425+
filename: str | bytes | PathLike[Any],
1426+
mode: str,
1427+
flags: Literal[1024],
1428+
dont_inherit: bool = False,
1429+
optimize: int = -1,
1430+
*,
1431+
_feature_version: int = -1,
1432+
) -> _ast.AST: ...
1433+
@overload
1434+
def compile(
1435+
source: str | ReadableBuffer | _ast.Module | _ast.Expression | _ast.Interactive,
1436+
filename: str | bytes | PathLike[Any],
1437+
mode: str,
1438+
flags: int,
1439+
dont_inherit: bool = False,
1440+
optimize: int = -1,
1441+
*,
1442+
_feature_version: int = -1,
1443+
) -> Any: ...
14901444

14911445
copyright: _sitebuiltins._Printer
14921446
credits: _sitebuiltins._Printer

0 commit comments

Comments
 (0)