Skip to content

Commit 304e906

Browse files
committed
replacing ternary if expressions with the or operator
Fixes 9 FURB10 errors across 4 files
1 parent 02d277e commit 304e906

File tree

4 files changed

+9
-11
lines changed

4 files changed

+9
-11
lines changed

src/otdf_python/kas_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ def _handle_existing_scheme(self, parsed) -> str:
154154
# Reconstruct URL preserving the path (especially /kas prefix)
155155
try:
156156
# Create URL preserving the path component for proper endpoint routing
157-
path = parsed.path if parsed.path else ""
157+
path = parsed.path or ""
158158
normalized_url = f"{scheme}://{parsed.hostname}:{port}{path}"
159159
logging.debug(f"normalized url [{parsed.geturl()}] to [{normalized_url}]")
160160
return normalized_url

src/otdf_python/nanotdf.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ def _serialize_policy_object(self, obj):
7070
if isinstance(obj, PolicyBody):
7171
# Convert data_attributes to dataAttributes and use null instead of empty array
7272
result = {
73-
"dataAttributes": obj.data_attributes if obj.data_attributes else None,
74-
"dissem": obj.dissem if obj.dissem else None,
73+
"dataAttributes": obj.data_attributes or None,
74+
"dissem": obj.dissem or None,
7575
}
7676
return result
7777
elif isinstance(obj, AttributeObject):
@@ -115,14 +115,12 @@ def _prepare_policy_data(self, config: NanoTDFConfig) -> tuple[bytes, str]:
115115
tuple: (policy_body, policy_type)
116116
117117
"""
118-
attributes = config.attributes if config.attributes else []
118+
attributes = config.attributes or []
119119
policy_object = self._create_policy_object(attributes)
120120
policy_json = json.dumps(
121121
policy_object, default=self._serialize_policy_object
122122
).encode("utf-8")
123-
policy_type = (
124-
config.policy_type if config.policy_type else "EMBEDDED_POLICY_PLAIN_TEXT"
125-
)
123+
policy_type = config.policy_type or "EMBEDDED_POLICY_PLAIN_TEXT"
126124

127125
if policy_type == "EMBEDDED_POLICY_PLAIN_TEXT":
128126
policy_body = policy_json

src/otdf_python/tdf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,8 @@ def _serialize_policy_object(self, obj):
183183
if isinstance(obj, PolicyBody):
184184
# Convert data_attributes to dataAttributes and use null instead of empty array
185185
result = {
186-
"dataAttributes": obj.data_attributes if obj.data_attributes else None,
187-
"dissem": obj.dissem if obj.dissem else None,
186+
"dataAttributes": obj.data_attributes or None,
187+
"dissem": obj.dissem or None,
188188
}
189189
return result
190190
elif isinstance(obj, AttributeObject):

tests/support_otdfctl_args.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,8 @@ def _generate_target_mode_tdf(
183183
creds_file=creds_file,
184184
input_file=input_file,
185185
output_file=output_file,
186-
mime_type=mime_type if mime_type else "text/plain",
187-
attributes=attributes if attributes else None,
186+
mime_type=mime_type or "text/plain",
187+
attributes=attributes or None,
188188
tdf_type="tdf3",
189189
target_mode=target_mode,
190190
)

0 commit comments

Comments
 (0)