python / python/mypy

New parser deviates from old parser in edge cases with function type comments

Open
#21,948 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug topic-parser
Dominant language
Python
Stars
20.6k
Forks
3.3k
PR merge metrics
PR metrics pending

Description

This is a follow-up for https://github.com/python/mypy/pull/21823. Most notably we get a false negative in situations like this:

class A:
    def f(self):
        # type: () -> None
        def g(x):
            # type: () -> None  # Error not detected: signature has too few parameters
            pass

cc @JukkaL

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 reproducing the nested class and function example in the issue, then compare how the new and old parsers handle function type comments. The work is done when the new parser detects the inner function signature's missing parameter, matching the old parser's behavior in this edge case.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.