emacs-lsp / lsp-mode

Emacs client/library for the Language Server Protocol
https://emacs-lsp.github.io/lsp-mode
GNU General Public License v3.0
4.72k stars 860 forks source link

LSP pyright false positive #4476

Open vikigenius opened 2 weeks ago

vikigenius commented 2 weeks ago

Thank you for the bug report

Bug description

False positive in lsp pyright doesn't match command line behavior

Steps to reproduce

from typing import Literal

class LWPRSService(object):
    """Lightweight PRS Service."""

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

Shows

[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
      ]
    }
  ]
}

Expected behavior

When I run the file through the pyright CLI no diagnostics are produced.

Setting reportUnusedVarialbe = false in pyproject.toml has no effect. And it should not be needed in the first place.

Which Language Server did you use?

lsp-pyright

OS

Linux

Error callstack

No response

Anything else?

I do see a bunch of messages Invalid face reference: lsp-flycheck-info-unnecessary [79 times]. Don't know if that is related.