-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Enforce ruff/flake8-simplify rules (SIM) #10462
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
8aedfaf
to
8ec7121
Compare
@@ -8980,7 +8979,7 @@ def pad( | |||
variables[name] = var | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
b2ac9ec
Compare
SIM118 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)`
it looks like there's a |
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 |
This reverts commit 5d5bc5b.
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 |
My wrong, if it's a dataset, obviously keeping |
I would probably go by rule rather than adding noqas but no strong view! |
whats-new.rst
api.rst