Skip to content

Commit

Permalink
Enable Ruff's default rules (#342)
Browse files Browse the repository at this point in the history
Signed-off-by: Fabrice Normandin <fabrice.normandin@gmail.com>
  • Loading branch information
lebrice authored Jan 31, 2025
1 parent ba5139e commit a1c5167
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 13 deletions.
4 changes: 1 addition & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@ testpaths = ["test", "simple_parsing"]
norecursedirs = ["examples", "docs"]

[tool.ruff.lint]
select = ["I", "UP"]
# TODO: Fix the imports in __init__.py files and enable these:
# select = ["E4", "E7", "E9", "I", "UP"]
select = ["E4", "E7", "E9", "I", "UP"]

[tool.docformatter]
in-place = true
Expand Down
16 changes: 8 additions & 8 deletions test/test_decoding.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ def test_encode_something(simple_attribute):

@dataclass
class SomeClass(Serializable):
d: dict[str, some_type] = dict_field()
l: list[tuple[some_type, some_type]] = list_field()
t: dict[str, Optional[some_type]] = dict_field()
d: dict[str, some_type] = dict_field() # pyright: ignore[reportInvalidTypeForm]
some_list: list[tuple[some_type, some_type]] = list_field() # pyright: ignore[reportInvalidTypeForm]
t: dict[str, Optional[some_type]] = dict_field() # pyright: ignore[reportInvalidTypeForm]
# w: Dict[str, Union[some_type, int, str, None, str, None]] = dict_field()

b = SomeClass()
b.d.update({"hey": expected_value})
b.l.append((expected_value, expected_value))
b.some_list.append((expected_value, expected_value))
b.t.update({"hey": None, "hey2": expected_value})
# b.w.update({
# "hey": None,
Expand Down Expand Up @@ -85,14 +85,14 @@ class Container(Serializable, Generic[ItemT]):

@dataclass
class SomeClass(Serializable):
d: dict[str, some_type] = dict_field()
l: list[tuple[some_type, some_type]] = list_field()
t: dict[str, Optional[some_type]] = dict_field()
d: dict[str, some_type] = dict_field() # pyright: ignore[reportInvalidTypeForm]
some_list: list[tuple[some_type, some_type]] = list_field() # pyright: ignore[reportInvalidTypeForm]
t: dict[str, Optional[some_type]] = dict_field() # pyright: ignore[reportInvalidTypeForm]
# w: Dict[str, Union[some_type, int, str, None, str, None]] = dict_field()

b = SomeClass()
b.d.update({"hey": expected_value})
b.l.append((expected_value, expected_value))
b.some_list.append((expected_value, expected_value))
b.t.update({"hey": None, "hey2": expected_value})
# b.w.update({
# "hey": None,
Expand Down
4 changes: 2 additions & 2 deletions test/test_union.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class Foo(TestSetup):
assert foo.x == "bob"

foo = Foo.setup("--x 2")
assert foo.x == 2 and type(foo.x) is int
assert foo.x == 2 and isinstance(foo.x, int)


def test_union_type_raises_error():
Expand All @@ -31,4 +31,4 @@ class Foo2(TestSetup):
foo = Foo2.setup("--x bob")

foo = Foo2.setup("--x 2")
assert foo.x == 2 and type(foo.x) is int
assert foo.x == 2 and isinstance(foo.x, int)

0 comments on commit a1c5167

Please sign in to comment.