Skip to content

Commit 34400d0

Browse files
committed
bump ruff to 0.14.8, enable FBT002
1 parent 39afed4 commit 34400d0

File tree

8 files changed

+33
-27
lines changed

8 files changed

+33
-27
lines changed

nested_diff/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ class Differ:
100100

101101
def __init__( # noqa: PLR0913
102102
self,
103+
*,
103104
A=True, # noqa: N803
104105
N=True, # noqa: N803
105106
O=True, # noqa: E741 N803
@@ -253,7 +254,7 @@ class Iterator:
253254

254255
default_iterator = DEFAULT_HANDLER.iterate_diff
255256

256-
def __init__(self, handlers=None, sort_keys=False):
257+
def __init__(self, *, handlers=None, sort_keys=False):
257258
"""Initialize iterator.
258259
259260
Args:

nested_diff/cli.py

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def _decode_fmt_opts(opts):
5757
if opts is None:
5858
return {}
5959

60-
import json
60+
import json # noqa: PLC0415
6161

6262
return json.loads(opts)
6363

@@ -345,7 +345,7 @@ def __init__(self, **kwargs):
345345
"""
346346
super().__init__()
347347

348-
import json
348+
import json # noqa: PLC0415
349349

350350
self.encoder = json.JSONEncoder(**self.get_opts(kwargs))
351351

@@ -383,7 +383,7 @@ def __init__(self, **kwargs):
383383
"""
384384
super().__init__()
385385

386-
import json
386+
import json # noqa: PLC0415
387387

388388
self.decoder = json.JSONDecoder(**self.get_opts(kwargs))
389389

@@ -404,8 +404,8 @@ def __init__(self, **kwargs):
404404
"""
405405
super().__init__()
406406

407-
import configparser
408-
import io
407+
import configparser # noqa: PLC0415
408+
import io # noqa: PLC0415
409409

410410
self.encoder = configparser.ConfigParser(**self.get_opts(kwargs))
411411
self.stringio = io.StringIO()
@@ -430,7 +430,7 @@ def __init__(self, **kwargs):
430430
"""
431431
super().__init__()
432432

433-
import configparser
433+
import configparser # noqa: PLC0415
434434

435435
self.decoder = configparser.ConfigParser(**kwargs)
436436

@@ -457,7 +457,7 @@ def __init__(self, **kwargs):
457457
"""Initialize dumper."""
458458
super().__init__()
459459

460-
import pprint
460+
import pprint # noqa: PLC0415
461461

462462
self.codec = pprint.PrettyPrinter(**self.get_opts(kwargs))
463463

@@ -495,7 +495,7 @@ def __init__(self):
495495
"""Initialize dumper."""
496496
super().__init__()
497497

498-
import tomli_w
498+
import tomli_w # noqa: PLC0415
499499

500500
self.codec = tomli_w
501501

@@ -512,9 +512,9 @@ def __init__(self):
512512
super().__init__()
513513

514514
if sys.version_info >= (3, 11):
515-
import tomllib # pragma nocover
515+
import tomllib # pragma nocover # noqa: PLC0415
516516
else:
517-
import tomli as tomllib # pragma nocover
517+
import tomli as tomllib # pragma nocover # noqa: PLC0415
518518

519519
self.codec = tomllib
520520

@@ -535,12 +535,12 @@ def __init__(self, **kwargs):
535535
"""
536536
super().__init__()
537537

538-
import yaml
538+
import yaml # noqa: PLC0415
539539

540540
try:
541-
from yaml import CSafeDumper as ImportedYamlDumper
541+
from yaml import CSafeDumper as ImportedYamlDumper # noqa: PLC0415
542542
except ImportError:
543-
from yaml import SafeDumper as ImportedYamlDumper
543+
from yaml import SafeDumper as ImportedYamlDumper # noqa: PLC0415
544544

545545
class _YamlDumper(ImportedYamlDumper):
546546
def represent_scalar(self, tag, value, style=None):
@@ -588,16 +588,18 @@ def __init__(self, **kwargs):
588588
"""
589589
super().__init__()
590590

591-
import yaml
591+
import yaml # noqa: PLC0415
592592

593593
try:
594-
from yaml import CSafeLoader as YamlLoader
594+
from yaml import CSafeLoader as YamlLoader # noqa: PLC0415
595595
except ImportError:
596-
from yaml import SafeLoader as YamlLoader
596+
from yaml import SafeLoader as YamlLoader # noqa: PLC0415
597597

598-
from yaml.nodes import MappingNode as YamlMappingNode
599-
from yaml.nodes import ScalarNode as YamlScalarNode
600-
from yaml.nodes import SequenceNode as YamlSequenceNode
598+
from yaml.nodes import ( # noqa: PLC0415
599+
MappingNode as YamlMappingNode,
600+
ScalarNode as YamlScalarNode,
601+
SequenceNode as YamlSequenceNode,
602+
)
601603

602604
self.opts = self.get_opts(kwargs)
603605
self.yaml = yaml

nested_diff/diff_tool.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ def __init__( # noqa: PLR0913
279279
kwargs: Passed to base formatter as is.
280280
281281
"""
282-
import nested_diff.formatters
282+
import nested_diff.formatters # noqa: PLC0415
283283

284284
if fmt == 'term':
285285
base_class = nested_diff.formatters.TermFormatter

nested_diff/formatters.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ class AbstractFormatter:
2727

2828
def __init__(
2929
self,
30+
*,
3031
handlers=None,
3132
indent=' ',
3233
line_separator='\n',

nested_diff/handlers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ class FloatHandler(ScalarHandler):
148148

149149
handled_type = float
150150

151-
def __init__(self, nans_equal=False):
151+
def __init__(self, *, nans_equal=False):
152152
"""Initialize handler.
153153
154154
Args:

pyproject.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ test = [
5757
'pytest',
5858
'pytest-cov',
5959
'pytest-ruff',
60-
'ruff==0.11.13',
60+
'ruff==0.14.8',
6161
]
6262

6363
[project.scripts]
@@ -97,7 +97,6 @@ ignore = [
9797
'ANN', # TODO: enable
9898
'EM101', # Exception must not use a string literal, assign to variable...
9999
'EM102', # Exception must not use an f-string literal
100-
'FBT002', # TODO: enable
101100
'PTH', # ... should be replaced by `Path...
102101
'SIM105', # contextlib.suppress is slower than try-except-pass
103102
'TRY003', # Avoid specifying long messages outside the exception class
@@ -114,5 +113,8 @@ ignore = [
114113
[tool.ruff.lint.flake8-quotes]
115114
inline-quotes = 'single'
116115

116+
[tool.ruff.lint.isort]
117+
combine-as-imports = true
118+
117119
[tool.ruff.lint.pydocstyle]
118120
convention = 'google'

tests/test_diff.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ def test_different_object_attributes():
8080
reason='reducer_override appeared in 3.8',
8181
)
8282
def test_custom_dumper():
83-
import io
84-
import pickle
83+
import io # noqa: PLC0415
84+
import pickle # noqa: PLC0415
8585

8686
class ClassToTestDiff:
8787
pass

tests/test_patch.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def test_text_unsupported_op():
5858

5959

6060
def test_incorrect_diff_format():
61-
with pytest.raises(ValueError, match="{'garbage': 'passed'}"):
61+
with pytest.raises(ValueError, match=r"{'garbage': 'passed'}"):
6262
Patcher().patch({}, {'garbage': 'passed'})
6363

6464

0 commit comments

Comments
 (0)