ref: Add ALL ruff rules for tests (#4183)

Add ALL ruff rules for tests
This commit is contained in:
Christophe Bornet 2024-10-19 22:41:37 +02:00 • committed by GitHub
commit f96f2eaf8a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
67 changed files with 421 additions and 361 deletions

View file

@ -45,52 +45,52 @@ class TestInput:
assert set(post_process_type(SequenceABC[float])) == {float}
# Union types
assert set(post_process_type(Union[int, str])) == {int, str}
assert set(post_process_type(Union[int, SequenceABC[str]])) == {int, str}
assert set(post_process_type(Union[int, SequenceABC[int]])) == {int}
assert set(post_process_type(Union[int, str])) == {int, str} # noqa: UP007
assert set(post_process_type(Union[int, SequenceABC[str]])) == {int, str} # noqa: UP007
assert set(post_process_type(Union[int, SequenceABC[int]])) == {int} # noqa: UP007
# Nested Union with lists
assert set(post_process_type(Union[list[int], list[str]])) == {int, str}
assert set(post_process_type(Union[int, list[str], list[float]])) == {int, str, float}
assert set(post_process_type(Union[list[int], list[str]])) == {int, str} # noqa: UP007
assert set(post_process_type(Union[int, list[str], list[float]])) == {int, str, float} # noqa: UP007
# Custom data types
assert set(post_process_type(Data)) == {Data}
assert set(post_process_type(list[Data])) == {Data}
# Union with custom types
assert set(post_process_type(Union[Data, str])) == {Data, str}
assert set(post_process_type(Union[Data, int, list[str]])) == {Data, int, str}
assert set(post_process_type(Union[Data, str])) == {Data, str} # noqa: UP007
assert set(post_process_type(Union[Data, int, list[str]])) == {Data, int, str} # noqa: UP007
# Empty lists and edge cases
assert set(post_process_type(list)) == {list}
assert set(post_process_type(Union[int, None])) == {int, NoneType}
assert set(post_process_type(Union[None, list[None]])) == {None, NoneType}
assert set(post_process_type(Union[int, None])) == {int, NoneType} # noqa: UP007
assert set(post_process_type(Union[None, list[None]])) == {None, NoneType} # noqa: UP007
# Handling complex nested structures
assert set(post_process_type(Union[SequenceABC[int | str], list[float]])) == {int, str, float}
assert set(post_process_type(Union[int | list[str] | list[float], str])) == {int, str, float}
assert set(post_process_type(Union[SequenceABC[int | str], list[float]])) == {int, str, float} # noqa: UP007
assert set(post_process_type(Union[int | list[str] | list[float], str])) == {int, str, float} # noqa: UP007
# Non-generic types should return as is
assert set(post_process_type(dict)) == {dict}
assert set(post_process_type(tuple)) == {tuple}
# Union with custom types
assert set(post_process_type(Union[Data, str])) == {Data, str}
assert set(post_process_type(Union[Data, str])) == {Data, str} # noqa: UP007
assert set(post_process_type(Data | str)) == {Data, str}
assert set(post_process_type(Data | int | list[str])) == {Data, int, str}
# More complex combinations with Data
assert set(post_process_type(Data | list[float])) == {Data, float}
assert set(post_process_type(Data | Union[int, str])) == {Data, int, str}
assert set(post_process_type(Data | Union[int, str])) == {Data, int, str} # noqa: UP007
assert set(post_process_type(Data | list[int] | None)) == {Data, int, type(None)}
assert set(post_process_type(Data | Union[float, None])) == {Data, float, type(None)}
assert set(post_process_type(Data | Union[float, None])) == {Data, float, type(None)} # noqa: UP007
# Multiple Data types combined
assert set(post_process_type(Union[Data, str | float])) == {Data, str, float}
assert set(post_process_type(Union[Data | float | str, int])) == {Data, int, float, str}
assert set(post_process_type(Union[Data, str | float])) == {Data, str, float} # noqa: UP007
assert set(post_process_type(Union[Data | float | str, int])) == {Data, int, float, str} # noqa: UP007
# Testing with nested unions and lists
assert set(post_process_type(Union[list[Data], list[int | str]])) == {Data, int, str}
assert set(post_process_type(Union[list[Data], list[int | str]])) == {Data, int, str} # noqa: UP007
assert set(post_process_type(Data | list[float | str])) == {Data, float, str}
def test_input_to_dict(self):
@ -157,7 +157,7 @@ class TestPostProcessType:
assert post_process_type(list[int]) == [int]
def test_union_type(self):
assert set(post_process_type(Union[int, str])) == {int, str}
assert set(post_process_type(Union[int, str])) == {int, str} # noqa: UP007
def test_custom_type(self):
class CustomType:
@ -175,4 +175,4 @@ class TestPostProcessType:
class CustomType:
pass
assert set(post_process_type(Union[CustomType, int])) == {CustomType, int}
assert set(post_process_type(Union[CustomType, int])) == {CustomType, int} # noqa: UP007