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

type mismatch: base parameter is type "Any", override parameter is type "Any" #6

Open
Serega124 opened this issue Feb 4, 2022 · 5 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@Serega124
Copy link

Serega124 commented Feb 4, 2022

When creating a new plugin with a text command and adding a type annotation to run() method, an error appears in the Diagnostics panel:

buffer://sublime/150:
    6:7   error   Method "run" overrides class "TextCommand" in an incompatible manner ​Pyright: reportIncompatibleMethodOverride 
                    Parameter 2 type mismatch: base parameter is type "Any", override parameter is type "Any"

code:

from typing import Any
import sublime_plugin


class ExampleCommand(sublime_plugin.TextCommand):
  def run(self, edit: Any):
    self.view.insert(edit, 0, "Hello, World!")

LSP-pyright 1.1.136

@jfcherng
Copy link
Member

jfcherng commented Feb 4, 2022

I can't reproduce this with your code. No matter it's a saved file or a buffer (from Tools > Developer > New Plugin). Though I don't think this issue comes from here.


Not the cause, but it should be edit: sublime.Edit.

@jfcherng jfcherng added the need more info Needs more information label Feb 4, 2022
@Serega124
Copy link
Author

Serega124 commented Feb 4, 2022

Tested on a clean portable Sublime Text (installed only LSP and LSP-pyright packages) - got the same error.

image

I know that it should be sublime.Edit, but I just tried to annotate it to the Any type so that all errors are gone, but instead I got a cryptic error saing type Any is incompatible with type Any. Maybe it's a pyright type checker issue?

@jfcherng
Copy link
Member

jfcherng commented Feb 4, 2022

Tested on a clean portable Sublime Text (installed only LSP and LSP-pyright packages) - got the same error.

Not reproduce-able.

demo_x264.mp4

@Serega124
Copy link
Author

Sorry, I forgot to mention the setting "python.analysis.typeCheckingMode": "strict" that enables the reportIncompatibleMethodOverride rule.

@jfcherng
Copy link
Member

jfcherng commented Feb 4, 2022

Sorry, I forgot to mention the setting "python.analysis.typeCheckingMode": "strict" that enables the reportIncompatibleMethodOverride rule.

Yes, that's the reason. But I have no idea how to fix that unfortunately since run accepts literally any amount of any arguments, which I guess "strict" doesn't like.

class TextCommand(Command):
    run: Callable[..., None]

If someone comes up a solution, I am definitely welcome. Just open a pull request 😄

@jfcherng jfcherng added bug Something isn't working and removed need more info Needs more information labels Feb 4, 2022
@jfcherng jfcherng added the help wanted Extra attention is needed label Feb 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants