emacs-lsp / lsp-pyright

lsp-mode :heart: pyright
https://emacs-lsp.github.io/lsp-pyright
GNU General Public License v3.0
285 stars 24 forks source link

Pyright always reports unused violations even after disabling them #94

Open vikigenius opened 2 months ago

vikigenius commented 2 months ago
from typing import Literal

class MyService(object):
    """My Service."""

    def __init__(self, env: Literal["prod", "dev", "stg"] = "stg", country: Literal["us", "ca"] = "us") -> None:
        super().__init__()
        a = 4

I have the following in my pyproject.toml

[tool.pyright]
include = ["src"]
exclude = ["notebooks"]
reportUnusedVariable = false
reportUnusedImport = false

And pyright still complains about all 3 env is not accessed country is not accessed and a is not accessed

seagle0128 commented 2 months ago

Did pyright server report the events?

vikigenius commented 2 months ago

@seagle0128 yep. Here are the server logs. They seem to be reported with a severity of 4 which is not any of error, warning, info.

[Trace - 05:41:47 PM] Received notification 'textDocument/publishDiagnostics'.
Params: {
  "uri": "file:///home/void/Projects/Research/lexutilair/src/lexutilair/prs.py",
  "version": 0,
  "diagnostics": [
    {
      "range": {
        "start": {
          "line": 8,
          "character": 23
        },
        "end": {
          "line": 8,
          "character": 26
        }
      },
      "message": "\"env\" is not accessed",
      "severity": 4,
      "source": "Pyright",
      "tags": [
        1
      ]
    },
    {
      "range": {
        "start": {
          "line": 8,
          "character": 67
        },
        "end": {
          "line": 8,
          "character": 74
        }
      },
      "message": "\"country\" is not accessed",
      "severity": 4,
      "source": "Pyright",
      "tags": [
        1
      ]
    }
  ]
}

The logs doesn't show a is not accessed because I added it later as a test and didn't recapture the logs.

seagle0128 commented 2 months ago

So it's an issue of pyright server or configuration issue.