Skip to content

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

Open
@DanielYang59

Description

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

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions