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

Disable specific warnings #627

Closed
goffi-contrib opened this issue Sep 22, 2021 · 6 comments
Closed

Disable specific warnings #627

goffi-contrib opened this issue Sep 22, 2021 · 6 comments
Assignees

Comments

@goffi-contrib
Copy link

goffi-contrib commented Sep 22, 2021

Hello,

thanks for maintaining this, I'm new to CoC and CoC-PyRight and it is quite pleasant to use.

Would it be possible to add a way to disable a specific warning (by its message for instance)? I'm using double underscore __ to mark a variable as unused (I'm not using single underscore as it is conflicting with the use of it for gettext), this is a common practice, and Coc-Pyright is showing a "not accessed" hint for that.

I know that there have been previous discussion (#107) pointing to diagnostic.showUnused but I want to keep unused variables hints, only disable it for this specific variable name.

Furthermore, Pyright is incorrectly marking some Twisted methods such as reactor.listenTCP or reactor.listenSSL as not existing, it would be useful to indicate that this must be ignored.

Thanks

@fannheyward
Copy link
Owner

Pyright is incorrectly marking some Twisted methods

Try to create typing files by :CocCommand pyright.createtypestub twisted.

You can put # type: ignore at the end of line to disable Pyright checking.

@goffi-contrib
Copy link
Author

thanks for your feedback, I knew about the # type: ignore way but it's not nice and polluting the code to put this in many places. I guess this should be fixed on Twisted level has I've found other people having this issue (e.g. here: https://stackoverflow.com/questions/66850481/mypy-typing-errors-when-upgrading-to-twisted-21-2-0)

What about the double dash issue? It's a common way to mark a variable as ignored, and disabling completely the feature is not a good option.

@fannheyward
Copy link
Owner

It's a common way to mark a variable as ignored

I don't find it's a common way, in most Python practices, we use _ to suppress the unused var.

@goffi-contrib
Copy link
Author

goffi-contrib commented Sep 22, 2021

It's a common way to mark a variable as ignored

I don't find it's a common way, in most Python practices, we use _ to suppress the unused var.

Except when it conflicts with the common use of assigning _ to gettext.

After a quick search I can see several references to it:

@fannheyward fannheyward reopened this Sep 22, 2021
@fannheyward fannheyward self-assigned this Sep 22, 2021
@fannheyward
Copy link
Owner

Try coc-pyright v1.1.171, coc-pyright will ignore "__" is not accessed diagnostics.

microsoft/pyright#1931

@goffi-contrib
Copy link
Author

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants