python / python/mypy

Do not check LSP compatibility of `plugin_generated` nodes

Open
#20,008 4 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

feature topic-plugins
Dominant language
Python
Stars
20.6k
Forks
3.3k
PR merge metrics
PR metrics pending

Description

Feature

When plugins add some methods or variables, it should be their responsibility to decide whether the override should be checked for LSP compat.

Pitch

This is already hitting the pydantic plugin, for example, resulting in some very weird workaround involving adding an unresolved classmethod decorator that shouldn't be there at all.

In many cases a plugin-generated method has narrower signature than the base class definition, and there is no way to make it compatible with super definition (which can't be removed either to support other typecheckers). We still want a plugin to be able to define such a signature without introducing noise, assuming that the plugin author is already aware that such behavior violates LSP.

It should become easy to run LSP checks manually from plugin code. Checker API should be extended to include the necessary methods, or we'll see increased use of mypy internals or unexpectedly omitting LSP checks altogether because they are too tricky to implement correctly.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing mypy's LSP compatibility checks and how plugin-generated nodes are represented. Define the checker API needed for plugins to run these checks manually, and add coverage showing that plugin-generated overrides avoid automatic LSP diagnostics while ordinary overrides remain checked.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
compilers, devtools
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.