Skip to content

PyYAML: Permit width: float for pure-Python dump(...) #8973

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Nov 8, 2022
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
27 changes: 14 additions & 13 deletions stubs/PyYAML/yaml/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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 *
Expand Down Expand Up @@ -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 = ...,
): ...
Expand All @@ -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 = ...,
Expand All @@ -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 = ...,
Expand All @@ -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 = ...,
Expand All @@ -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 = ...,
Expand All @@ -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 = ...,
Expand All @@ -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 = ...,
Expand All @@ -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 = ...,
Expand All @@ -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 = ...,
Expand All @@ -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 = ...,
Expand All @@ -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 = ...,
Expand All @@ -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 = ...,
Expand All @@ -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 = ...,
Expand Down
11 changes: 8 additions & 3 deletions stubs/PyYAML/yaml/dumper.pyi
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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,
Expand All @@ -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 = ...,
Expand All @@ -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 = ...,
Expand All @@ -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 = ...,
Expand Down