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

Coc-pyright removes sourcery's quickfixes #172

Closed
anstadnik opened this issue Dec 4, 2020 · 10 comments
Closed

Coc-pyright removes sourcery's quickfixes #172

anstadnik opened this issue Dec 4, 2020 · 10 comments
Labels
help wanted Extra attention is needed

Comments

@anstadnik
Copy link

Sourcery is an AI tool that refactors code link. It adds items to :CocFix, when it finds any ways to improve the code. When coc-pyright is installed, it somehow overwrites those fixes.

e.g.
image
When coc-pyright is not installed, :CocFix changes dict() to {}. With coc-pyright installed, nvim prints [coc.nvim] No quickfix action available.

Code from the image
class choises_printer:
    def __init__(self):
        self.choise = dict()

    def set_choise(l: int, i: int):
        self.choise[l] = i
Please tell me if you need any additional information.
@fannheyward
Copy link
Owner

Try <Plug>(coc-codeaction-line).

@anstadnik
Copy link
Author

Hm, for me it doesn't work. I tried this as well as <Plug>(coc-codeaction). Does it work for you?

@fannheyward
Copy link
Owner

Sorry, I don't use Sourcery, can not to test or debug this.

@fannheyward fannheyward added the help wanted Extra attention is needed label Dec 4, 2020
@marcoaaguiar
Copy link

I use both Sourcery and PyRight. Could you post a code example so that we are talking about the same thing?
I can try to reproduce it.

@anstadnik
Copy link
Author

Hi @marcoaaguiar. The code is in the first comment, you just need to open the fold

@marcoaaguiar
Copy link

My bad didn't notice.

Anyway, it works just fine for me. I used the method that I explained in sourcery-ai/sourcery#43 (comment) to setup Sourcery (Downloading the release from their Github page)
In your screenshot, I noticed that PyRight is not complaining about the lack o self on the second method (which is in mine).
I will try to upgrade Sourcery to see if it is an issue with their side.

@marcoaaguiar
Copy link

With the latest version of everything (coc.nvim, pyright, sourcery), I cannot reproduce the error you posted. That is, quickfix works just fine.

@marcoaaguiar
Copy link

@anstadnik, are you running all the latest versions?

@anstadnik
Copy link
Author

Yes, I can confirm that the issue is gone

@fvdnabee
Copy link

fvdnabee commented Oct 1, 2021

I'm experiencing a similar issue with the following snippet (from the sourcery tutorial):

def dictionary_get():
    dictionary = {}
    data = ""
    if "message" in dictionary:
        data = dictionary["message"]

CocDiagnostics output:

test.py|3 col 1 info| [sourcery refactoring/diagnostic] Sourcery - Replace if statement with if expression, Simplify dictionary access using default get [I]
test.py|3 col 5 H| [Pyright] "data" is not accessed [H]
test.py|5 col 9 H| [Pyright] "data" is not accessed [H]

image

With the pyright error present, <Plug>(coc-codeaction) with the cursor on any line in the buffer does not offer the sourcery suggestion. When I move the cursor to L2 or L4 (one line above/below where vim highlights the sourcery suggestion and the pyright error) and execute (coc-codeaction-line) I get the sourcery suggestion for the line below/above:
image

Then when I update the snippet to fix the pyright error to:

def dictionary_get():
    dictionary = {}
    data = ""
    if "message" in dictionary:
        data = dictionary["message"]
   return data

CocDiagnostics lists no more pyright errors, only the same sourcery suggestion:

test.py|3 col 1 info| [sourcery refactoring/diagnostic] Sourcery - Replace if statement with if expression, Simplify dictionary access using default get, Inline variable that is immediately returned [I]

And (coc-codeaction) shows the sourcery suggestion with the cursor on any line in the buffer and (coc-codeaction-line) shows the suggestion on L2, L3 and L4, as you would expect.

It appears the pyright error is swallowing the coc-codeaction sourcery suggestion for the entire buffer and the coc-codeaction-line sourcery suggestion on the line where the pyright error occurs. Whether this is an issue with pyright, coc-nvim or sourcery I can't say...

Finally, note that doHover does work on the line with the pyright error (for the original snippet):
image
It's just the codeaction that doesn't work (annoyingly).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants