Skip to content

Commit 59caf06

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 148ed5f commit 59caf06

File tree

6 files changed

+44
-29
lines changed

6 files changed

+44
-29
lines changed

_test/test_block_seq_local_indent.py

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
1+
import io
2+
from typing import Any, Dict, List, Text # NOQA
13

24
import pytest
3-
import io
4-
import ruyaml # NOQA
5-
from .roundtrip import round_trip, dedent
65

6+
import ruyaml # NOQA
77
from ruyaml import YAML
8-
from ruyaml.util import load_yaml_guess_indent
9-
from ruyaml.scalarbool import ScalarBoolean
108
from ruyaml.comments import CommentedSeq
11-
from ruyaml.representer import RoundTripRepresenter, ScalarNode
129
from ruyaml.constructor import RoundTripConstructor
13-
from typing import Text, Any, Dict, List # NOQA
10+
from ruyaml.representer import RoundTripRepresenter, ScalarNode
11+
from ruyaml.scalarbool import ScalarBoolean
12+
from ruyaml.util import load_yaml_guess_indent
13+
14+
from .roundtrip import dedent, round_trip
1415

1516

1617
class ScalarNodePositioned(ScalarNode):
1718
lc_position = None
1819

1920

2021
class ScalarBooleanStable(ScalarBoolean):
21-
2222
def __new__(cls: Any, boolval, origrepr, anchor=None) -> Any:
2323
b = ScalarBoolean.__new__(cls, boolval, anchor=anchor)
2424
b.original_bool_repr = origrepr
2525
return b
2626

2727

28-
#def represent_list2(self, data):
28+
# def represent_list2(self, data):
2929
# dedede
3030
# RoundTripRepresenter.add_representer(CommentedSeq, represent_list2)
3131

@@ -36,7 +36,9 @@ class BetterRoundTripConstructor(RoundTripConstructor):
3636

3737
class BetterRoundTripRepresenter(RoundTripRepresenter):
3838
def represent_bool(self, data, anchor=None):
39-
ret = self.represent_scalar('tag:yaml.org,2002:bool', data.original_bool_repr, anchor=anchor)
39+
ret = self.represent_scalar(
40+
'tag:yaml.org,2002:bool', data.original_bool_repr, anchor=anchor
41+
)
4042
return ret
4143

4244
def TOTO_represent_sequence(self, tag, data):
@@ -46,8 +48,8 @@ def TOTO_represent_sequence(self, tag, data):
4648
local_block_seq_ident = -1
4749

4850

49-
#BetterRoundTripConstructor.add_constructor('tag:yaml.org,2002:bool', BetterRoundTripConstructor.construct_yaml_bool)
50-
#BetterRoundTripRepresenter.add_representer(ScalarBooleanStable, BetterRoundTripRepresenter.represent_bool)
51+
# BetterRoundTripConstructor.add_constructor('tag:yaml.org,2002:bool', BetterRoundTripConstructor.construct_yaml_bool)
52+
# BetterRoundTripRepresenter.add_representer(ScalarBooleanStable, BetterRoundTripRepresenter.represent_bool)
5153

5254

5355
def round_trip_stabler(
@@ -68,7 +70,6 @@ def round_trip_stabler(
6870

6971

7072
class TestStability:
71-
7273
def test_blockseq1(self):
7374
round_trip(
7475
"""
@@ -101,8 +102,8 @@ def test_blockseq3(self):
101102
"""
102103
)
103104

104-
class TestStabilityStabler:
105105

106+
class TestStabilityStabler:
106107
def test_blockseq1(self):
107108
round_trip_stabler(
108109
"""

_test/test_bools.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
1+
import io
2+
from typing import Any, Dict, List, Text # NOQA
13

24
import pytest
3-
import io
4-
import ruyaml # NOQA
5-
from .roundtrip import round_trip, dedent
65

6+
import ruyaml # NOQA
77
from ruyaml import YAML
8-
from ruyaml.util import load_yaml_guess_indent
9-
from ruyaml.scalarbool import ScalarBoolean
108
from ruyaml.comments import CommentedSeq
11-
from ruyaml.representer import RoundTripRepresenter, ScalarNode
129
from ruyaml.constructor import RoundTripConstructor
13-
from typing import Text, Any, Dict, List # NOQA
10+
from ruyaml.representer import RoundTripRepresenter, ScalarNode
11+
from ruyaml.scalarbool import ScalarBoolean
12+
from ruyaml.util import load_yaml_guess_indent
13+
14+
from .roundtrip import dedent, round_trip
1415

1516

1617
def round_trip_stabler(
@@ -31,7 +32,6 @@ def round_trip_stabler(
3132

3233

3334
class TestStability:
34-
3535
def test_lowercase_boolean(self):
3636
round_trip(
3737
"""

lib/ruyaml/events.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ def __init__(
186186

187187

188188
class SequenceStartEvent(CollectionStartEvent):
189-
__slots__ = ('block_seq_indent', )
189+
__slots__ = ('block_seq_indent',)
190190

191191
def __init__(
192192
self,
@@ -201,7 +201,17 @@ def __init__(
201201
block_seq_indent=None,
202202
):
203203
# type: (Any, Any, Any, Any, Any, Any, Any, Optional[int]) -> None
204-
CollectionStartEvent.__init__(self, anchor, tag, implicit, start_mark, end_mark, flow_style, comment, nr_items)
204+
CollectionStartEvent.__init__(
205+
self,
206+
anchor,
207+
tag,
208+
implicit,
209+
start_mark,
210+
end_mark,
211+
flow_style,
212+
comment,
213+
nr_items,
214+
)
205215
self.block_seq_indent = block_seq_indent
206216

207217

lib/ruyaml/main.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -244,9 +244,11 @@ def constructor(self):
244244
# type: () -> Any
245245
attr = '_' + sys._getframe().f_code.co_name
246246
if not hasattr(self, attr):
247-
cnst = self.Constructor(preserve_quotes=self.preserve_quotes,
248-
preserve_bools=self.preserve_bools,
249-
loader=self)
247+
cnst = self.Constructor(
248+
preserve_quotes=self.preserve_quotes,
249+
preserve_bools=self.preserve_bools,
250+
loader=self,
251+
)
250252
cnst.allow_duplicate_keys = self.allow_duplicate_keys
251253
setattr(self, attr, cnst)
252254
return getattr(self, attr)

lib/ruyaml/nodes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ def __init__(
121121

122122

123123
class SequenceNode(CollectionNode):
124-
__slots__ = ('block_seq_indent', )
124+
__slots__ = ('block_seq_indent',)
125125
id = 'sequence'
126126

127127
def __init__(

lib/ruyaml/representer.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -825,7 +825,9 @@ def set_block_seq_indent(self, node, sequence):
825825
if not sequence.lc.data:
826826
return
827827
for lc_item in sequence.lc.data.values():
828-
local_block_seq_indent = min(local_block_seq_indent, lc_item[1] - 2) # Why '2'?
828+
local_block_seq_indent = min(
829+
local_block_seq_indent, lc_item[1] - 2
830+
) # Why '2'?
829831
node.block_seq_indent = local_block_seq_indent
830832

831833
def merge_comments(self, node, comments):

0 commit comments

Comments
 (0)