Skip to content

Commit b828ec1

Browse files
Ken KundertKen Kundert
authored andcommitted
fix lint nits
1 parent b4a40cd commit b828ec1

File tree

11 files changed

+35
-23
lines changed

11 files changed

+35
-23
lines changed

examples/accumulation/settings.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from inform import Error, full_stop, os_error
22
import nestedtext as nt
3-
from pathlib import Path
43

54
schema = dict(
65
name = str,

examples/accumulation/test_read_settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# imports {{{1
2-
from flatten_dict import flatten, unflatten
2+
from flatten_dict import flatten
33
from functools import partial
44
from inform import Error
55
from parametrize_from_file import parametrize

examples/test_examples.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
# encoding: utf8
22

33
from pathlib import Path
4-
from shlib import Run, cd, cwd, to_path
4+
from shlib import Run, cd, to_path
55
from textwrap import dedent
6-
import pytest
76
import sys
87

98
tests_dir = Path(__file__).parent

examples/validation/deploy_voluptuous.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import nestedtext as nt
44
from voluptuous import Schema, Coerce, MultipleInvalid
55
from voluptuous_errors import report_voluptuous_errors
6-
from inform import error, full_stop, terminate
6+
from inform import terminate
77
from pprint import pprint
88

99
schema = Schema({

nestedtext/nestedtext.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ def get_keys(
147147
keys: tuple[str | int, ...],
148148
keymap: dict[tuple[str | int, ...], Location],
149149
original: bool = ...,
150-
strict: bool | string = ...,
150+
strict: bool | str = ...,
151151
sep: str = ...,
152152
) -> tuple[str | int, ...] | str:
153153
...

proposed_tests/README.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,11 @@ types:
219219
string item
220220
unrecognized
221221

222+
As an example, if the implementation you are testing is limited to Minimal
223+
NestedText, you can filter out tests that use the more advance features of
224+
NestedText by simply ignoring those test cases that contain *inline dict*,
225+
*inline list* or *key item*.
226+
222227

223228
Caveats
224229
-------

proposed_tests/test_nt.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
# IMPORTS {{{1
22
from functools import partial
3-
from inform import cull, indent, render
3+
from inform import cull, render
44
from parametrize_from_file import parametrize
55
from pathlib import Path
6-
from voluptuous import Schema, Optional, Required, Any, Invalid
6+
from voluptuous import Schema, Required, Any
77
from base64 import b64decode
88
import nestedtext as nt
9-
import json
109

1110
# GLOBALS {{{1
1211
TEST_SUITE = Path('tests.json')
@@ -105,7 +104,6 @@ def test_nt(tmp_path, load_in, load_out, load_err, encoding, types, request):
105104
except UnicodeDecodeError as e:
106105
problematic = e.object[e.start:e.end]
107106
prefix = e.object[:e.start]
108-
suffix = e.object[e.start:]
109107
lineno = prefix.count(b'\n')
110108
_, _, bol = prefix.rpartition(b'\n')
111109
eol, _, _ = e.object[e.start:].partition(b'\n')
@@ -134,11 +132,11 @@ def test_nt(tmp_path, load_in, load_out, load_err, encoding, types, request):
134132
# vary between implementations and with dump options.
135133
try:
136134
dumped = nt.dumps(result)
137-
except nt.NestedTextError as e:
135+
except nt.NestedTextError:
138136
checker.check(None, result, "dumping")
139137

140138
try:
141139
result = nt.loads(dumped, top=any)
142140
checker.check(load_out, result, "re-loading")
143-
except nt.NestedTextError as e:
141+
except nt.NestedTextError:
144142
checker.check(None, result, "re-loading")

pyproject.toml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,17 @@ changelog = "https://github.com/KenKundert/nestedtext/blob/master/doc/releases.r
3333
[build-system]
3434
requires = ["flit_core >=2,<4"]
3535
build-backend = "flit_core.buildapi"
36+
37+
[tool.pytest.ini_options]
38+
addopts = "--tb=short"
39+
40+
[tool.ruff]
41+
exclude = [".tox", "doc"]
42+
43+
[tool.ruff.lint]
44+
select = ["F"]
45+
ignore = []
46+
47+
[tool.ruff.lint.per-file-ignores]
48+
"nestedtext/__init__.py" = ["F401"]
49+
"examples/parametrize_from_file/test_misc.py" = ["F401"]

tests/test_nestedtext.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,9 @@
77
from pathlib import Path
88
from functools import wraps
99
from io import StringIO
10-
from inform import Error, Info, render, indent, join, dedent
10+
from inform import Error, Info, join, dedent
1111
from quantiphy import Quantity
1212
import subprocess
13-
import json
1413
import os
1514

1615
test_api = Path(__file__).parent / 'official_tests' / 'api'
@@ -1195,7 +1194,6 @@ def test_key_utilities():
11951194

11961195
unknown_norm = ('user_names', 'Anastacia Pickett Cheek', 'unknown key')
11971196
unknown_orig = ('user Names', 'Anastacia Pickett__Cheek', 'unknown key')
1198-
unknown_index = ('scores', 3)
11991197

12001198
def normalize_key(key, parent_keys):
12011199
if parent_keys == ('user_names',):
@@ -1290,7 +1288,7 @@ def test_load_dialect():
12901288
@parametrize(
12911289
"top,expected", [(any,None), (dict,{}), (list,[]), (str,"")]
12921290
)
1293-
def test_empty_blank_lines(top, expected):
1291+
def test_empty(top, expected):
12941292
# just blank lines
12951293
document = ""
12961294

@@ -1599,7 +1597,7 @@ def __nestedtext_converter__(self):
15991597
converters = {ntInfo: False}
16001598
with pytest.raises(nt.NestedTextError) as exc:
16011599
dump(y, tmp_path, width=80, converters=converters)
1602-
assert str(exc.value) == f"info: unsupported type (ntInfo)."
1600+
assert str(exc.value) == "info: unsupported type (ntInfo)."
16031601

16041602
# converting arrow object
16051603
date = '1969-07-20'
@@ -2070,7 +2068,7 @@ def test_binary_round_trip(tmp_path):
20702068

20712069
# dump nestedtext to a binary file
20722070
with nt_path.open('wb') as f:
2073-
test_nt = nt.dump(orig_data, f)
2071+
nt.dump(orig_data, f)
20742072

20752073
# read nestedtext from a binary file
20762074
with nt_path.open('rb') as f:

tests/test_random.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# maps CR/LF and CR to LF, so the same is done to the input before comparing it
77
# to the output.
88

9-
from hypothesis import assume, given, settings, strategies as st
9+
from hypothesis import given, settings, strategies as st
1010
import nestedtext as nt
1111
from random import randint
1212
import re
@@ -77,7 +77,7 @@ def test_dicts(data):
7777

7878
# test normal dump
7979
result = nt.loads(nt.dumps(data), top=dict)
80-
assert nt.loads(nt.dumps(data), top=dict) == expected
80+
assert result == expected
8181

8282
# test dump with inlines
8383
content = nt.dumps(data, width=999)

0 commit comments

Comments
 (0)