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

use-named-expression removes comment before the code #434

Open
3 tasks done
DanielYang59 opened this issue Aug 15, 2024 · 1 comment
Open
3 tasks done

use-named-expression removes comment before the code #434

DanielYang59 opened this issue Aug 15, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@DanielYang59
Copy link

Checklist

Description

I believe it's a duplicate of #280 and mentioned in FAQ, but I didn't see it being resolved in latest version of sourcery-cli (not sure when would a new engine be released). I think comments above the code should not have been removed in any case.

Code snippet that reproduces issue

Noticed this when trying to refactor the following code for pymatgen.

sourcery review src/pymatgen/analysis/graphs.py --enable use-named-expression --fix
-        # check we're not trying to add a duplicate edge
-        # there should only ever be at most one edge
-        # between a given (site, jimage) pair and another
-        # (site, jimage) pair
-        existing_edge_data = self.graph.get_edge_data(from_index, to_index)
-        if existing_edge_data:
+        if existing_edge_data := self.graph.get_edge_data(from_index, to_index):

Debug Information

IDE Version:
Visual Studio Code 1.92.1

Sourcery Version:
Sourcery 1.20.0

Operating system and Version:
MacOS Sonama 14.6.1

@DanielYang59 DanielYang59 added the bug Something isn't working label Aug 15, 2024
@alibimahdi
Copy link

Yes this is not good to delete comments. Comments are there for a reason , it would be appreciated that the comments are not deleted by refactoring

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

No branches or pull requests

2 participants