sourcery icon indicating copy to clipboard operation
sourcery copied to clipboard

Sourcery does not recognizes docstrings

Open psstpakGithub opened this issue 2 years ago • 1 comments

Sourcery fails to recognize python docstrings, and the refactoring it offers delete the entire class/function

the "problem" it reports is Sourcery - Remove unnecessary call to str() within print() (removes comment)

Sourcery Version v0.12.3

Code editor or IDE name and version

Python 3.9 in VS Code

OS name and version

Windows 10 21H2

psstpakGithub avatar Jul 18 '22 09:07 psstpakGithub

Hi @psstpakGithub, thanks for reporting. I can't easily reproduce the issue - Sourcery is correctly preserving docstrings in the example below. If possible, can you share an example of the code Sourcery is breaking on?

class HatPicker(Picker):
    """Interface for picking hats."""

    def pick_hat(self, available_hats: Dict[Label, Hat]):
        """Gets your favourite hat from the list of available hats."""

        if self.favourite_hat in available_hats:
            hat_to_wear = available_hats[self.favourite_hat]
        else:
            hat_to_wear = NO_HAT
        return hat_to_wear
# becomes
class HatPicker(Picker):
    """Interface for picking hats."""

    def pick_hat(self, available_hats: Dict[Label, Hat]):
        """Gets your favourite hat from the list of available hats."""

        return available_hats.get(self.favourite_hat, NO_HAT)

bm424 avatar Jul 18 '22 11:07 bm424

Hi @psstpakGithub - will close this as we can't reproduce it. Please do re-open it with a code example and we'll work to resolve it.

Hellebore avatar Aug 15 '22 07:08 Hellebore