Skip to content

Commit f63bad8

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 8f2a770 commit f63bad8

File tree

2 files changed

+21
-18
lines changed

2 files changed

+21
-18
lines changed

_test/test_bools.py

Lines changed: 16 additions & 15 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(
@@ -60,8 +62,8 @@ def round_trip_stabler(
6062
yaml = ruyaml.YAML()
6163
yaml.preserve_quotes = True
6264
yaml.preserve_bools = True
63-
#yaml.Constructor = BetterRoundTripConstructor
64-
#yaml.Representer = BetterRoundTripRepresenter
65+
# yaml.Constructor = BetterRoundTripConstructor
66+
# yaml.Representer = BetterRoundTripRepresenter
6567
data = yaml.load(doutp)
6668
buf = io.StringIO()
6769
yaml.dump(data, stream=buf)
@@ -70,7 +72,6 @@ def round_trip_stabler(
7072

7173

7274
class TestStability:
73-
7475
def test_lowercase_boolean(self):
7576
round_trip(
7677
"""

lib/ruyaml/main.py

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

0 commit comments

Comments
 (0)