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 hint-level diagnostics #271

Closed
patnr opened this issue Jan 20, 2021 · 19 comments
Closed

Disable hint-level diagnostics #271

patnr opened this issue Jan 20, 2021 · 19 comments

Comments

@patnr
Copy link

patnr commented Jan 20, 2021

Thanks for all the great work!

Is there any way to get rid of "hint" type diagnostics? See attached screenshot:
hints

I've tried all of these with no luck:

# pyright: reportGeneralTypeIssues=false
# pyright: reportUnusedVariable=false
# pyright: off
@yaegassy
Copy link
Contributor

yaegassy commented Jan 21, 2021

@patricknraanes [H] (Hint) level messages cannot be disabled by pyright.

If you change the diagnostic.showUnused or diagnostic.level setting in "coc-settings.json", it will not be displayed.

{
  // ...snip
  "diagnostic.showUnused": false,
  // ...snip
}

or

{
  // ...snip
  // Set level to information or higher
  "diagnostic.level": "information",
  // ...snip
}

@fannheyward
Copy link
Owner

microsoft/pyright#982 (comment)

Pyright is using the "Unnecessary" tag, and VS Code uses that to determine which ranges to display in gray.

coc-pyright will remove the Unnecessary tag.

@fannheyward
Copy link
Owner

Releases with v1.1.103, CocUpdate and give it a try.

@fannheyward fannheyward reopened this Jan 21, 2021
@fannheyward
Copy link
Owner

fannheyward commented Jan 21, 2021

Maybe we should not remove Unnecessary support directly. Currently, there are two ways to disable the Unecessary diagnostics:

  1. remove the Unnecessary tag support from coc-pyright
  2. use diagnostic.showUnused

I'll look into this whether these two ways conflict.

@fannheyward
Copy link
Owner

The latest coc-pyright, v1.1.103, has removed the Unnecessary tag support, Pyright will not return Unnecessary diagnostics, there is no conflict with diagnostic.showUnused.

I'll leave this issue open to see whether this will cause other unexpected problems.

@HudsonMC16
Copy link

HudsonMC16 commented Feb 19, 2021

@fannheyward I'm not sure if this is related, but I am not receiving any unused notifications now. I can see unused import warnings with the appropriate diagnostic overrides set, but no unused variable diagnostics. Is this still under investigation? I'm using this config:

// vim: set filetype=jsonc
{
    "python.analysis.typeCheckingMode": "basic",
    "diagnostic.warningSign": "",
    "diagnostic.errorSign": "",
    "diagnostic.infoSign": "",
    "diagnostic.hintSign": "",
    "diagnostic.level": "information",
    "diagnostic.showUnused": true,
    "python.linting.enabled": true,
    "python.linting.pylintEnabled": true
    "python.analysis.diagnosticSeverityOverrides": {
       "reportUnusedImport": "warning",
       "reportUnusedClass": "warning",
       "reportUnusedFunction": "warning",
       "reportUnusedVariable": "warning"
    }
}

It does not appear any combination of diagnostic overrides or coc options produces the diagnostics. They do show up when using nvim lsp, however.

@HudsonMC16
Copy link

A bit of clarification:

I am receiving diagnostic warnings for variables declared but not used within that function's scope, but not for parameters included in the signature but not used within that function's scope. Perhaps this is handled by some other option?

@haoyun
Copy link

haoyun commented Feb 19, 2021

A bit of clarification:

I am receiving diagnostic warnings for variables declared but not used within that function's scope, but not for parameters included in the signature but not used within that function's scope. Perhaps this is handled by some other option?

I'm having the same issue. The defaut behavior seems to have been changed and this change was introduced recently. I do benefit from those hints. So I rolled back to an previous version of coc-pyright.

[email protected] works fine, but [email protected] breaks.

@fannheyward
Copy link
Owner

@haoyun @HudsonMC16 try v1.1.113.

@HudsonMC16
Copy link

HudsonMC16 commented Feb 22, 2021

Still no dice:
image

Only the unused variable is flagged, but not the unused testing function argument. Should I create a new issue?

@yaegassy
Copy link
Contributor

@HudsonMC16 In my environment, "v1.1.113" shows up fine.

coc-pyirght-271-1

Has your coc-pyright been updated to v1.1.113?

I checked your coc-settings.json in this comment. #271 (comment)

You have customized the diagnostic.level, so I think that is affecting it, Does it work correctly if you set your "diagnostic.level" to hint (default value) instead of information?

@lsaint
Copy link

lsaint commented Feb 23, 2021

@patricknraanes [H] (Hint) level messages cannot be disabled by pyright.

If you change the diagnostic.showUnused or diagnostic.level setting in "coc-settings.json", it will not be displayed.

{
  // ...snip
  "diagnostic.showUnused": false,
  // ...snip
}

or

{
  // ...snip
  // Set level to information or higher
  "diagnostic.level": "information",
  // ...snip
}

pyright language server 1.1.113

@classmethod
def func(cls, a, unuse1):
    unuse2 = 2
    return a

in this case, cls and unuse1 are act the same.
unuse2 worked.
how to turn ("cls" is not accessed) off and keep the message about unuse1 ?

image

@yaegassy
Copy link
Contributor

yaegassy commented Feb 23, 2021

@lsaint In that case, make sure to show the Hint level message. ("diagnostic.showUnused": true and "diagnostic.level": "hint")

For example, add del cls to your code and try it.

coc-pyirght-271-2

@lsaint
Copy link

lsaint commented Feb 23, 2021

@yaegassy
I know that add del cls to function will disable the ("cls" is not accessed) message, but that's not i wanted.
Sometimes, It's normal for self or cls not in use in Python, i don't want it to be treated as a warning or error or hint.
But other args such as unuse1 should always be treated as a warning.

@yaegassy
Copy link
Contributor

@lsaint Check the documentation of pyright itself to see if there are any control settings for diagnostic messages that you expect, and try them out. https://github.com/microsoft/pyright/blob/master/docs/configuration.md#type-check-diagnostics-settings

If the configuration you expect does not exist, you may want to suggest it in pyright's itself GitHub issue or on gitter.

@HudsonMC16
Copy link

You have customized the diagnostic.level, so I think that is affecting it, Does it work correctly if you set your "diagnostic.level" to hint (default value) instead of information?

@fannheyward Ah, this was totally it. Sorry, I misunderstood how the configs inherit from eachother, and figured that with a diagnostic override setting reportUnusedVariable to warning, it would show up as warnings. After removing the line you referenced, everything appears to be working fine. Having the additional diagnostic override set produces two diagnostics (a warning and an error), so I just removed the overrides, and that's not a huge deal at all. Thanks for your help and everything you're doing!

@alejo90
Copy link

alejo90 commented Mar 1, 2021

Sorry, I'm a little confused. Is there a setting combination that would lead to self and cls not being marked as unused while other arguments that are unused remain marked as such?

@fannheyward
Copy link
Owner

You can disable the self not accessed hint from coc-pyright v1.1.129, set pyright.disableSelfClsNotAccessed in your coc-settings.json.

@lsaint
Copy link

lsaint commented Apr 9, 2021

89fe02b

hmm, hard code, but it work well.

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

7 participants