sourcery icon indicating copy to clipboard operation
sourcery copied to clipboard

VSCode reports suggestions the CLI doesn't report

Open carlfriedrich opened this issue 2 years ago • 2 comments

Checklist

  • [x] I have searched the Sourcery documentation for the issue, and found nothing
  • [x] I have checked there are no open bugs referencing the same bug or problem

Description

I have installed the Sourcery plugin for VS Code. Furthermore I have set up the Sourcery CLI. Both of them are configured to use the same .sourcery.yaml config file.

Now VS Code reports some suggestions that the CLI does not report, e.g. the use-contextlib-suppress suggestion:

grafik

Even when I explicitly enable it on the command line, the CLI does not find any issues:

grafik

The same happens with extract-method and extract-duplicate-method.

Where does the difference in behavior come from? How can I configure VS Code and the CLI to report the same suggestions?

Code snippet that reproduces issue

#!/usr/bin/env python3

def main():
    try:
        invalid = 1 / 0
    except ZeroDivisionError:
        pass

if __name__ == "__main__":
    main()

Debug Information

IDE Version: VSCode 1.81.1

Sourcery Version: Sourcery 1.6.0

Operating system and Version: Ubuntu 22.04 via WSL

carlfriedrich avatar Aug 28 '23 11:08 carlfriedrich

Hello, @carlfriedrich! Thanks for reporting this issue.

This is a known limitation in the Sourcery CLI - it cannot yet handle refactorings that add imports. The same limitation applies to both extract-method and extract-duplicate-method, as you mentioned. Enhancing the CLI to have those capabilities is already on our roadmap but may still take some time to be implemented.

ruancomelli avatar Aug 28 '23 20:08 ruancomelli

@ruancomelli Thanks for your quick reply. Looking forward to the implementation.

carlfriedrich avatar Aug 29 '23 05:08 carlfriedrich