Skip to content

Commit b34c22a

Browse files
Apply ruff/Pylint rule PLR5501
PLR5501 Use `elif` instead of `else` then `if`, to reduce indentation
1 parent 9ee9f3d commit b34c22a

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

xarray/coding/strings.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -129,15 +129,14 @@ def validate_char_dim_name(strlen, encoding, name) -> str:
129129
"To silence this warning either remove 'char_dim_name' from encoding or provide a fitting name."
130130
)
131131
char_dim_name = f"{new_dim_name}{strlen}"
132-
else:
133-
if (
134-
original_shape := encoding.get("original_shape", [-1])[-1]
135-
) != -1 and original_shape != strlen:
136-
emit_user_level_warning(
137-
f"String dimension length mismatch on variable {name!r}. '{original_shape}' provided by encoding, but data has length of '{strlen}'. Using '{char_dim_name}{strlen}' instead of {char_dim_name!r} to prevent possible naming clash.\n"
138-
f"To silence this warning remove 'original_shape' from encoding."
139-
)
140-
char_dim_name = f"{char_dim_name}{strlen}"
132+
elif (
133+
original_shape := encoding.get("original_shape", [-1])[-1]
134+
) != -1 and original_shape != strlen:
135+
emit_user_level_warning(
136+
f"String dimension length mismatch on variable {name!r}. '{original_shape}' provided by encoding, but data has length of '{strlen}'. Using '{char_dim_name}{strlen}' instead of {char_dim_name!r} to prevent possible naming clash.\n"
137+
f"To silence this warning remove 'original_shape' from encoding."
138+
)
139+
char_dim_name = f"{char_dim_name}{strlen}"
141140
else:
142141
char_dim_name = f"string{strlen}"
143142

0 commit comments

Comments
 (0)