Skip to content
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

refactor use-any can break existing code #191

Closed
lonico opened this issue Feb 10, 2022 · 4 comments
Closed

refactor use-any can break existing code #191

lonico opened this issue Feb 10, 2022 · 4 comments
Assignees
Labels
bug Something isn't working next release This will be fixed in next release

Comments

@lonico
Copy link

lonico commented Feb 10, 2022

Issue description or question

-        self.ontap_version['valid'] = True
-        for key in self.ontap_version:
-            if self.ontap_version[key] == -1:
-                self.ontap_version['valid'] = False
-                break
+        self.ontap_version['valid'] = all(
+            self.ontap_version[key] != -1 for key in self.ontap_version
+        )

(variable) ontap_version: dict[str, str | int]

Sourcery - Use any() instead of for loop, Invert any/all to simplify comparisons sourcery(refactoring)

The proposed change fails when self.ontap_version['valid'] == -1.

(I agree the existing code is icky. A value of None or False would have been better.)

Sourcery Version

v0.10.2

Code editor or IDE name and version

vscode

OS name and version

Alpine 3.14.0.1 in WSL using VSCode on Windows

@Hellebore Hellebore added the bug Something isn't working label Feb 10, 2022
@Hellebore Hellebore self-assigned this Feb 10, 2022
@Hellebore
Copy link
Collaborator

Thanks for raising!
I don't quite understand the difference in behaviour - could you give a few more details?

@ruancomelli
Copy link
Contributor

@lonico we were able to reproduce this. We'll release a fix for it as soon as possible.

@ruancomelli ruancomelli assigned ruancomelli and unassigned Hellebore Feb 11, 2022
@ruancomelli ruancomelli added the next release This will be fixed in next release label Feb 12, 2022
@ruancomelli
Copy link
Contributor

ruancomelli commented Feb 12, 2022

@lonico we implemented a fix for this bug. It will be available in the next nightly release and in v0.10.3.
Thanks for reporting this issue!

@Hellebore
Copy link
Collaborator

Now released in 0.10.3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working next release This will be fixed in next release
Projects
None yet
Development

No branches or pull requests

3 participants