python / python/mypy

misc instance check on `super` triggers despite second argument being Any

Open
#14,723 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Bug Report
Error is not suppressed, since apparently Any isn't considered an instance of DynamicClass/MyClass.

To Reproduce

class MyClass:
    ...
DynamicClass: type[MyClass]
def foo(self: Any):
    super(DynamicClass, self).foo()

Actual Behavior

error: Argument 2 for "super" not an instance of argument 1  [misc]

Your Environment

  • Mypy version used: 1.0.0
  • Python version used: 3.11.1

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 running the provided Python reproduction with mypy 1.0.0 and confirm the [misc] error for super(DynamicClass, self). Trace the type-checking path for super's second argument and add a regression test showing that Any suppresses this instance check; done means the example no longer reports the error.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.