Skip to content

Commit f15387e

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

8 files changed

Lines changed: 48 additions & 35 deletions

File tree

sdjson/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ def dumps(
340340
separators=separators,
341341
default=default,
342342
sort_keys=sort_keys,
343-
**kwargs
343+
**kwargs,
344344
).encode(obj)
345345

346346

sdjson/__init__.pyi

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ def dump(
125125
separators: Optional[Tuple[str, str]] = ...,
126126
default: Optional[Callable[[Any], Any]] = ...,
127127
sort_keys: bool = ...,
128-
**kwargs: Any
128+
**kwargs: Any,
129129
) -> None: ...
130130

131131
def dumps(
@@ -140,7 +140,7 @@ def dumps(
140140
separators: Optional[Tuple[str, str]] = ...,
141141
default: Optional[Callable[[Any], Any]] = ...,
142142
sort_keys: bool = ...,
143-
**kwargs: Any
143+
**kwargs: Any,
144144
) -> str: ...
145145

146146
def loads(
@@ -152,7 +152,7 @@ def loads(
152152
parse_int: Optional[Callable[[str], Any]] = ...,
153153
parse_constant: Optional[Callable[[str], Any]] = ...,
154154
object_pairs_hook: Optional[Callable[[List[Tuple[Any, Any]]], Any]] = ...,
155-
**kwargs: Any
155+
**kwargs: Any,
156156
) -> Any: ...
157157

158158
def load(
@@ -164,7 +164,7 @@ def load(
164164
parse_int: Optional[Callable[[str], Any]] = ...,
165165
parse_constant: Optional[Callable[[str], Any]] = ...,
166166
object_pairs_hook: Optional[Callable[[List[Tuple[Any, Any]]], Any]] = ...,
167-
**kwargs: Any
167+
**kwargs: Any,
168168
) -> Any: ...
169169

170170
class JSONEncoder(json.JSONEncoder):
@@ -179,7 +179,7 @@ class JSONEncoder(json.JSONEncoder):
179179
sort_keys: bool = ...,
180180
indent: Optional[int] = ...,
181181
separators: Optional[Tuple[str, str]] = ...,
182-
default: Optional[Callable[..., Any]] = ...
182+
default: Optional[Callable[..., Any]] = ...,
183183
) -> None: ...
184184

185185
def default(self, o: Any) -> Any: ...
@@ -207,7 +207,7 @@ class JSONDecoder(json.JSONDecoder):
207207
parse_int: Optional[Callable[[str], Any]] = ...,
208208
parse_constant: Optional[Callable[[str], Any]] = ...,
209209
strict: bool = ...,
210-
object_pairs_hook: Optional[Callable[[List[Tuple[str, Any]]], Any]] = ...
210+
object_pairs_hook: Optional[Callable[[List[Tuple[str, Any]]], Any]] = ...,
211211
) -> None: ...
212212

213213
def decode(self, s: str, _w: Callable[..., Any] = ...) -> Any: ... # _w is undocumented

tests/stdlib_tests/test_dump.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def test_dump_skipkeys() -> None:
3737
[
3838
({True: False, False: True}, '{"false": true, "true": false}'),
3939
({2: 3.0, 4.0: 5, False: 1, 6: True}, '{"false": 1, "2": 3.0, "4.0": 5, "6": true}'),
40-
]
40+
],
4141
)
4242
def test_encode_truefalse(data: Set, expects: str):
4343
assert sdjson.dumps(data, sort_keys=True) == expects

tests/stdlib_tests/test_fail.py

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -145,12 +145,12 @@ def __test_invalid_input(data: str, msg: str, idx: int) -> None:
145145
(
146146
'{"spam":42',
147147
"Unterminated object starting at" if PYPY else "Expecting ',' delimiter",
148-
1 if PYPY else 10
148+
1 if PYPY else 10,
149149
),
150150
('{"spam":42,', property_name_string, 11),
151151
('"', "Unterminated string starting at", 0),
152152
('"spam', "Unterminated string starting at", 0),
153-
]
153+
],
154154
)
155155
def test_truncated_input(data: str, msg: str, idx: int):
156156
__test_invalid_input(data, msg, idx)
@@ -165,13 +165,19 @@ def test_truncated_input(data: str, msg: str, idx: int):
165165
('[42 "spam"', "Unexpected '\"' when decoding array" if PYPY else "Expecting ',' delimiter", 4),
166166
pytest.param("[42,]", "Illegal trailing comma before end of array", 3, marks=min_version((3, 13))),
167167
pytest.param(
168-
"[42,]", "Unexpected ']'" if PYPY else "Expecting value", 4, marks=max_version((3, 12))
168+
"[42,]",
169+
"Unexpected ']'" if PYPY else "Expecting value",
170+
4,
171+
marks=max_version((3, 12)),
169172
),
170173
('{"spam":[42}', "Unexpected '}' when decoding array" if PYPY else "Expecting ',' delimiter", 11),
171174
('["]', "Unterminated string starting at", 1),
172175
('["spam":', unexpected_colon, 7),
173176
pytest.param(
174-
'["spam",]', "Illegal trailing comma before end of array", 7, marks=min_version((3, 13))
177+
'["spam",]',
178+
"Illegal trailing comma before end of array",
179+
7,
180+
marks=min_version((3, 13)),
175181
),
176182
pytest.
177183
param('["spam",]', "Unexpected ']'" if PYPY else "Expecting value", 8, marks=max_version((3, 12))),
@@ -187,17 +193,17 @@ def test_truncated_input(data: str, msg: str, idx: int):
187193
(
188194
'{"spam":42 "ham"',
189195
"Unexpected '\"' when decoding object" if PYPY else "Expecting ',' delimiter",
190-
11
196+
11,
191197
),
192198
('[{"spam":42]', "Unexpected ']' when decoding object" if PYPY else "Expecting ',' delimiter", 11),
193199
pytest.param(
194200
'{"spam":42,}',
195201
"Illegal trailing comma before end of object",
196202
10,
197-
marks=min_version((3, 13))
203+
marks=min_version((3, 13)),
198204
),
199205
pytest.param('{"spam":42,}', property_name_string, 11, marks=max_version((3, 12))),
200-
]
206+
],
201207
)
202208
def test_unexpected_data(data: str, msg: str, idx: int):
203209
__test_invalid_input(data, msg, idx)
@@ -212,19 +218,20 @@ def test_unexpected_data(data: str, msg: str, idx: int):
212218
("{},{}", "Extra data", 2),
213219
('42,"spam"', "Extra data", 2),
214220
('"spam",42', "Extra data", 6),
215-
]
221+
],
216222
)
217223
def test_extra_data(data: str, msg: str, idx: int):
218224
__test_invalid_input(data, msg, idx)
219225

220226

221227
@pytest.mark.parametrize(
222-
"data, line, col, idx", [
228+
"data, line, col, idx",
229+
[
223230
('!', 1, 1, 0),
224231
(" !", 1, 2, 1),
225232
("\n!", 2, 1, 1),
226233
("\n \n\n !", 4, 6, 10),
227-
]
234+
],
228235
)
229236
def test_linecol(data: str, line: int, col: int, idx: int):
230237

tests/stdlib_tests/test_indent.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def test_indent() -> None:
3939
\t\t"field": "yes",
4040
\t\t"morefield": false
4141
\t}
42-
]"""
42+
]""",
4343
)
4444

4545
d1 = sdjson.dumps(h)

tests/stdlib_tests/test_separators.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def test_separators() -> None:
4040
"field" : "yes" ,
4141
"morefield" : false
4242
}
43-
]"""
43+
]""",
4444
)
4545

4646
d1 = sdjson.dumps(h)

tests/stdlib_tests/test_unicode.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def test_bytes_decode() -> None:
7575
("utf-16le", codecs.BOM_UTF16_LE),
7676
("utf-32be", codecs.BOM_UTF32_BE),
7777
("utf-32le", codecs.BOM_UTF32_LE),
78-
]:
78+
]:
7979
data = ["aµ€𝄠"]
8080
encoded = sdjson.dumps(data).encode(encoding)
8181
assert sdjson.loads(bom + encoded) == data

tests/test_load.py

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,17 @@ def test_none(tmp_pathplus: PathPlus) -> None:
3636
assert str(write_then_read(None, tmp_pathplus)) == "None" # Double check with string
3737

3838

39-
@pytest.mark.parametrize("value", [
40-
1,
41-
1234,
42-
12340000000,
43-
-1,
44-
-1234,
45-
-12340000000,
46-
])
39+
@pytest.mark.parametrize(
40+
"value",
41+
[
42+
1,
43+
1234,
44+
12340000000,
45+
-1,
46+
-1234,
47+
-12340000000,
48+
],
49+
)
4750
def test_int(value: int, tmp_pathplus: PathPlus) -> None:
4851
assert write_then_read(value, tmp_pathplus) == value
4952

@@ -63,7 +66,7 @@ def test_int(value: int, tmp_pathplus: PathPlus) -> None:
6366
-1.005,
6467
-1234.005,
6568
-12340000000.005,
66-
]
69+
],
6770
)
6871
def test_float(value: float, tmp_pathplus: PathPlus) -> None:
6972
assert write_then_read(value, tmp_pathplus) == value
@@ -82,17 +85,20 @@ def test_float(value: float, tmp_pathplus: PathPlus) -> None:
8285
("egg sausage and bacon", "egg sausage and bacon"),
8386
("egg and spam", "egg and spam"),
8487
("egg bacon and spam", "egg bacon and spam"),
85-
]
88+
],
8689
)
8790
def test_write_then_read(data, expected, tmp_pathplus: PathPlus):
8891
assert write_then_read(data, tmp_pathplus) == expected
8992

9093

9194
@pytest.mark.xfail
92-
@pytest.mark.parametrize("dictionary", [
93-
{True: False, False: True},
94-
{2: 3.0, 4.0: 5, False: 1, 6: True},
95-
])
95+
@pytest.mark.parametrize(
96+
"dictionary",
97+
[
98+
{True: False, False: True},
99+
{2: 3.0, 4.0: 5, False: 1, 6: True},
100+
],
101+
)
96102
def test_dict_failure(tmp_pathplus: PathPlus, dictionary: Dict) -> None:
97103
"""
98104
This test will fail because the boolean dictionary keys get read back in a lowercase strings

0 commit comments

Comments
 (0)