Skip to content

Commit f883e36

Browse files
authored
Merge pull request #227 from opsmill/pog-ruff056
Avoid providing a falsy fallback to `dict.get()`
2 parents c62efb9 + 680f491 commit f883e36

File tree

3 files changed

+3
-5
lines changed

3 files changed

+3
-5
lines changed

infrahub_sdk/analyzer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def variables(self) -> list[GraphQLQueryVariable]:
9191
else:
9292
data["default_value"] = variable.default_value.value
9393

94-
if not data.get("default_value", None) and non_null:
94+
if not data.get("default_value") and non_null:
9595
data["required"] = True
9696

9797
response.append(GraphQLQueryVariable(**data))

infrahub_sdk/node.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1074,7 +1074,7 @@ async def from_graphql(
10741074
timeout: int | None = None,
10751075
) -> Self:
10761076
if not schema:
1077-
node_kind = data.get("__typename", None) or data.get("node", {}).get("__typename", None)
1077+
node_kind = data.get("__typename") or data.get("node", {}).get("__typename", None)
10781078
if not node_kind:
10791079
raise ValueError("Unable to determine the type of the node, __typename not present in data")
10801080
schema = await client.schema.get(kind=node_kind, branch=branch, timeout=timeout)
@@ -1594,7 +1594,7 @@ def from_graphql(
15941594
timeout: int | None = None,
15951595
) -> Self:
15961596
if not schema:
1597-
node_kind = data.get("__typename", None) or data.get("node", {}).get("__typename", None)
1597+
node_kind = data.get("__typename") or data.get("node", {}).get("__typename", None)
15981598
if not node_kind:
15991599
raise ValueError("Unable to determine the type of the node, __typename not present in data")
16001600
schema = client.schema.get(kind=node_kind, branch=branch, timeout=timeout)

pyproject.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,6 @@ ignore = [
259259
"RUF005", # Consider `[*path, str(key)]` instead of concatenation
260260
"RUF015", # Prefer `next(iter(input_data["variables"].keys()))` over single element slice
261261
"RUF029", # Function is declared `async`, but doesn't `await` or use `async` features.
262-
"RUF056", # [*] Avoid providing a falsy fallback to `dict.get()` in boolean test positions. The default fallback `None` is already falsy.
263262
"S108", # Probable insecure usage of temporary file or directory
264263
"S311", # Standard pseudo-random generators are not suitable for cryptographic purposes
265264
"S701", # By default, jinja2 sets `autoescape` to `False`. Consider using `autoescape=True`
@@ -270,7 +269,6 @@ ignore = [
270269
"SIM114", # Combine `if` branches using logical `or` operator
271270
"SIM117", # Use a single `with` statement with multiple contexts instead of nested `with` statements
272271
"SIM118", # Use `key in dict` instead of `key in dict.keys)
273-
"SIM910", # Use `data.get(key)` instead of `data.get(key, None)`
274272
"TC003", # Move standard library import `collections.abc.Iterable` into a type-checking block
275273
"UP031", # Use format specifiers instead of percent format
276274
]

0 commit comments

Comments
 (0)