Uh oh!
There was an error while loading. Please reload this page.
Enforce ruff/flake8-simplify rules (SIM) - #10462
Conversation
8aedfaf to
8ec7121Compare| elif name in self.data_vars: | ||
| if utils.is_dict_like(constant_values): | ||
| if name in constant_values.keys(): | ||
| if name in constant_values: |
There was a problem hiding this comment.
I don't see how this change causes the new mypy errors:
Found 2 errors in 1 file (checked 191 source files)
xarray/core/dataset.py:8986: error: Value expression in dictionary comprehension has incompatible type "float | tuple[float, float] | Mapping[Any, float | tuple[float, float]]"; expected type "float | tuple[float, float]" [misc]
xarray/core/dataset.py:8991: error: Incompatible types in assignment (expression has type "float | tuple[float, float] | Mapping[Any, float | tuple[float, float]] | Mapping[Any, float | tuple[float, float] | Mapping[Any, float | tuple[float, float]]] | None", variable has type "float | tuple[float, float] | Mapping[Any, float | tuple[float, float]]") [assignment]
Wasn't this a pre-existing issue? If so, not sure why mypy only flags it after this change.
There was a problem hiding this comment.
yes agree it's confusing...
SIM102 Use a single `if` statement instead of nested `if` statements
SIM113 Use `enumerate()` for index variable in `for` loop
SIM114 Combine `if` branches using logical `or` operator
4ba8c59 to
b2ac9ecCompareSIM118 Use `key in dict` instead of `key in dict.keys()`
SIM905 Consider using a list literal instead of `str.split`
SIM910 Use `.get(...)` instead of `.get(..., None)`
keewis
commented
Jun 30, 2025
it looks like there's a |
max-sixty
commented
Jun 30, 2025
sorry re error, I'll revert. (but why no error in the tests?) no strong view re datasets; I was partial to the proposed code but no strong view |
no idea why it didn't fail here. to be clear, the difference is between iterating over Edit: thanks for reverting, although I think fixing the failing check in a new PR would have also worked |
DimitriPapadopoulos
commented
Jul 1, 2025
My wrong, if it's a dataset, obviously keeping |
max-sixty
commented
Jul 1, 2025
I would probably go by rule rather than adding noqas but no strong view! |
whats-new.rstapi.rst