Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Enable refurb lint rules in Ruff (#16889)

Patryk Zawadzkie839fd117520
diff --git a/pyproject.toml b/pyproject.toml
index 3a87933d96..edf842ec63 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -192,6 +192,7 @@ target-version = "py39"
"DTZ",
"E",
"F",
+ "FURB",
"G",
"I",
"ISC001",
diff --git a/saleor/graphql/core/connection.py b/saleor/graphql/core/connection.py
index 53187a67d6..2fe245077c 100644
--- a/saleor/graphql/core/connection.py
+++ b/saleor/graphql/core/connection.py
@@ -224,7 +224,7 @@ def _get_edges_for_connection(edge_type, qs, args, sorting_fields):
matching_records = list(qs)
if last:
- matching_records = list(reversed(matching_records))
+ matching_records.reverse()
if len(matching_records) <= requested_count:
start_slice = 0
page_info = _get_page_info(matching_records, cursor, first, last)
diff --git a/saleor/graphql/order/tests/queries/test_pagination.py b/saleor/graphql/order/tests/queries/test_pagination.py
index adf69bc674..c0ca1aa38a 100644
--- a/saleor/graphql/order/tests/queries/test_pagination.py
+++ b/saleor/graphql/order/tests/queries/test_pagination.py
@@ -215,7 +215,7 @@ def test_order_query_pagination_with_filter_created(
orders = content["data"]["orders"]["edges"]
total_count = content["data"]["orders"]["totalCount"]
- for i in range(total_count if total_count < page_size else page_size):
+ for i in range(min(total_count, page_size)):
assert orders[i]["node"]["total"]["gross"]["amount"] == orders_order[i]
assert expected_total_count == total_count
@@ -272,7 +272,7 @@ def test_order_query_pagination_with_filter_payment_status(
total_count = content["data"]["orders"]["totalCount"]
assert total_count == expected_total_count
- for i in range(total_count if total_count < page_size else page_size):
+ for i in range(min(total_count, page_size)):
assert orders[i]["node"]["total"]["gross"]["amount"] == orders_order[i]
@@ -309,7 +309,7 @@ def test_order_query_pagination_with_filter_status(
total_count = content["data"]["orders"]["totalCount"]
assert total_count == expected_total_count
- for i in range(total_count if total_count < page_size else page_size):
+ for i in range(min(total_count, page_size)):
assert orders[i]["node"]["total"]["gross"]["amount"] == orders_order[i]
@@ -479,7 +479,7 @@ def test_draft_order_query_pagination_with_filter_created(
orders = content["data"]["draftOrders"]["edges"]
total_count = content["data"]["draftOrders"]["totalCount"]
- for i in range(total_count if total_count < page_size else page_size):
+ for i in range(min(total_count, page_size)):
assert orders[i]["node"]["total"]["gross"]["amount"] == orders_order[i]
assert expected_total_count == total_count