diff --git a/stubs/PyYAML/yaml/__init__.pyi b/stubs/PyYAML/yaml/__init__.pyi index 04b68a86a07b..d3e05fcdd075 100644 --- a/stubs/PyYAML/yaml/__init__.pyi +++ b/stubs/PyYAML/yaml/__init__.pyi @@ -7,6 +7,7 @@ from . import resolver as resolver # Help mypy a bit; this is implied by loader from .constructor import BaseConstructor from .cyaml import * from .dumper import * +from .dumper import _Inf from .emitter import _WriteStream from .error import * from .events import * @@ -46,7 +47,7 @@ def emit( Dumper=..., canonical: bool | None = ..., indent: int | None = ..., - width: int | None = ..., + width: int | _Inf | None = ..., allow_unicode: bool | None = ..., line_break: str | None = ..., ): ... @@ -57,7 +58,7 @@ def serialize_all( Dumper=..., canonical: bool | None = ..., indent: int | None = ..., - width: int | None = ..., + width: int | _Inf | None = ..., allow_unicode: bool | None = ..., line_break: str | None = ..., encoding: str | None = ..., @@ -73,7 +74,7 @@ def serialize_all( Dumper=..., canonical: bool | None = ..., indent: int | None = ..., - width: int | None = ..., + width: int | _Inf | None = ..., allow_unicode: bool | None = ..., line_break: str | None = ..., encoding: str | None = ..., @@ -90,7 +91,7 @@ def serialize( *, canonical: bool | None = ..., indent: int | None = ..., - width: int | None = ..., + width: int | _Inf | None = ..., allow_unicode: bool | None = ..., line_break: str | None = ..., encoding: str | None = ..., @@ -107,7 +108,7 @@ def serialize( *, canonical: bool | None = ..., indent: int | None = ..., - width: int | None = ..., + width: int | _Inf | None = ..., allow_unicode: bool | None = ..., line_break: str | None = ..., encoding: str | None = ..., @@ -125,7 +126,7 @@ def dump_all( default_flow_style: bool | None = ..., canonical: bool | None = ..., indent: int | None = ..., - width: int | None = ..., + width: int | _Inf | None = ..., allow_unicode: bool | None = ..., line_break: str | None = ..., encoding: str | None = ..., @@ -144,7 +145,7 @@ def dump_all( default_flow_style: bool | None = ..., canonical: bool | None = ..., indent: int | None = ..., - width: int | None = ..., + width: int | _Inf | None = ..., allow_unicode: bool | None = ..., line_break: str | None = ..., encoding: str | None = ..., @@ -164,7 +165,7 @@ def dump( default_flow_style: bool | None = ..., canonical: bool | None = ..., indent: int | None = ..., - width: int | None = ..., + width: int | _Inf | None = ..., allow_unicode: bool | None = ..., line_break: str | None = ..., encoding: str | None = ..., @@ -184,7 +185,7 @@ def dump( default_flow_style: bool | None = ..., canonical: bool | None = ..., indent: int | None = ..., - width: int | None = ..., + width: int | _Inf | None = ..., allow_unicode: bool | None = ..., line_break: str | None = ..., encoding: str | None = ..., @@ -203,7 +204,7 @@ def safe_dump_all( default_flow_style: bool | None = ..., canonical: bool | None = ..., indent: int | None = ..., - width: int | None = ..., + width: int | _Inf | None = ..., allow_unicode: bool | None = ..., line_break: str | None = ..., encoding: str | None = ..., @@ -222,7 +223,7 @@ def safe_dump_all( default_flow_style: bool | None = ..., canonical: bool | None = ..., indent: int | None = ..., - width: int | None = ..., + width: int | _Inf | None = ..., allow_unicode: bool | None = ..., line_break: str | None = ..., encoding: str | None = ..., @@ -241,7 +242,7 @@ def safe_dump( default_flow_style: bool | None = ..., canonical: bool | None = ..., indent: int | None = ..., - width: int | None = ..., + width: int | _Inf | None = ..., allow_unicode: bool | None = ..., line_break: str | None = ..., encoding: str | None = ..., @@ -260,7 +261,7 @@ def safe_dump( default_flow_style: bool | None = ..., canonical: bool | None = ..., indent: int | None = ..., - width: int | None = ..., + width: int | _Inf | None = ..., allow_unicode: bool | None = ..., line_break: str | None = ..., encoding: str | None = ..., diff --git a/stubs/PyYAML/yaml/dumper.pyi b/stubs/PyYAML/yaml/dumper.pyi index 040aa0fed558..7203aaeab9c5 100644 --- a/stubs/PyYAML/yaml/dumper.pyi +++ b/stubs/PyYAML/yaml/dumper.pyi @@ -1,5 +1,6 @@ from collections.abc import Mapping from typing import Any +from typing_extensions import TypeAlias from yaml.emitter import Emitter from yaml.representer import BaseRepresenter, Representer, SafeRepresenter @@ -8,6 +9,10 @@ from yaml.serializer import Serializer from .emitter import _WriteStream +# Ideally, there would be a way to limit these values to only +/- float("inf"), +# but that's not possible at the moment (https://github.com/python/typing/issues/1160). +_Inf: TypeAlias = float + class BaseDumper(Emitter, Serializer, BaseRepresenter, BaseResolver): def __init__( self, @@ -16,7 +21,7 @@ class BaseDumper(Emitter, Serializer, BaseRepresenter, BaseResolver): default_flow_style: bool | None = ..., canonical: bool | None = ..., indent: int | None = ..., - width: int | None = ..., + width: int | _Inf | None = ..., allow_unicode: bool | None = ..., line_break: str | None = ..., encoding: str | None = ..., @@ -35,7 +40,7 @@ class SafeDumper(Emitter, Serializer, SafeRepresenter, Resolver): default_flow_style: bool | None = ..., canonical: bool | None = ..., indent: int | None = ..., - width: int | None = ..., + width: int | _Inf | None = ..., allow_unicode: bool | None = ..., line_break: str | None = ..., encoding: str | None = ..., @@ -54,7 +59,7 @@ class Dumper(Emitter, Serializer, Representer, Resolver): default_flow_style: bool | None = ..., canonical: bool | None = ..., indent: int | None = ..., - width: int | None = ..., + width: int | _Inf | None = ..., allow_unicode: bool | None = ..., line_break: str | None = ..., encoding: str | None = ...,