Skip to content

Commit 6ffc7ec

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

2 files changed

Lines changed: 7 additions & 23 deletions

File tree

src/cachier/core.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,7 @@ def _convert_args_kwargs(func, _is_method: bool, args: tuple, kwds: dict) -> dic
117117
args_as_kw[f"__varargs_{i}__"] = arg
118118

119119
# Init with default values
120-
kwargs = {
121-
k: v.default
122-
for k, v in sig.parameters.items()
123-
if v.default is not inspect.Parameter.empty
124-
}
120+
kwargs = {k: v.default for k, v in sig.parameters.items() if v.default is not inspect.Parameter.empty}
125121

126122
# Merge args expanded as kwargs and the original kwds
127123
kwargs.update(args_as_kw)

tests/test_varargs.py

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,9 @@ def test_different_args_produce_different_results(self):
3636
assert "('print', 'domains')" in result1
3737

3838
result2 = self.get_data("print", "users", "allfields")
39-
assert self.call_count == 2, (
40-
"Function should be called again with different args"
41-
)
39+
assert self.call_count == 2, "Function should be called again with different args"
4240
assert "('print', 'users', 'allfields')" in result2
43-
assert result1 != result2, (
44-
"Different args should produce different results"
45-
)
41+
assert result1 != result2, "Different args should produce different results"
4642

4743
def test_same_args_use_cache(self):
4844
"""Test that calling with same arguments uses cache."""
@@ -53,9 +49,7 @@ def test_same_args_use_cache(self):
5349
# Second call with same args should use cache
5450
previous_call_count = self.call_count
5551
result3 = self.get_data("print", "domains")
56-
assert self.call_count == previous_call_count, (
57-
"Function should not be called again (cache hit)"
58-
)
52+
assert self.call_count == previous_call_count, "Function should not be called again (cache hit)"
5953
assert result3 == result1
6054

6155
def test_another_set_of_args_cache_hit(self):
@@ -67,9 +61,7 @@ def test_another_set_of_args_cache_hit(self):
6761
# Second call with same args should use cache
6862
previous_call_count = self.call_count
6963
result4 = self.get_data("print", "users", "allfields")
70-
assert self.call_count == previous_call_count, (
71-
"Function should not be called again (cache hit)"
72-
)
64+
assert self.call_count == previous_call_count, "Function should not be called again (cache hit)"
7365
assert result4 == result2
7466

7567

@@ -188,9 +180,7 @@ def test_different_kwargs_produce_different_results(self):
188180
result1 = self.get_data(type="domains", action="print")
189181
assert self.call_count == 1
190182

191-
result2 = self.get_data(
192-
type="users", action="print", fields="allfields"
193-
)
183+
result2 = self.get_data(type="users", action="print", fields="allfields")
194184
assert self.call_count == 2
195185
assert result1 != result2
196186

@@ -404,9 +394,7 @@ def test_different_kw_only_produces_different_results(self):
404394
def test_different_kw_with_default_produces_different_results(self):
405395
"""Test that different kw_with_default values produce dif results."""
406396
result1 = self.get_data("r1", "a", "b", kw_only="k1")
407-
result3 = self.get_data(
408-
"r1", "a", "b", kw_only="k1", kw_with_default="custom"
409-
)
397+
result3 = self.get_data("r1", "a", "b", kw_only="k1", kw_with_default="custom")
410398
assert self.call_count == 2
411399
assert result3 != result1
412400

0 commit comments

Comments
 (0)