Skip to content

--untyped-calls-exclude should consider inheritance #16651

Open
@bersbersbers

Description

@bersbersbers

Bug Report

I think it would make sense to use --untyped-calls-exclude based on the defining class of an untyped function. However, that is not currently possible.

Related: #16653

To Reproduce

class Super:
    def draw(self):
        ...

class Class(Super):
    ...

Class().draw()

Expected Behavior

mypy --no-incremental --disallow-untyped-calls --untyped-calls-exclude=bug.Super bug.py

gives no error.

Actual Behavior

bug.py:8: error: Call to untyped function "draw" in typed context  [no-untyped-call]
Found 1 error in 1 file (checked 1 source file)

I can use --untyped-calls-exclude=bug.Class to work around this, but when inheriting from a class from an untyped library, it makes more sense to exclude the actual culprit and avoid false negatives (namely, other functions correctly typed in Class).

Your Environment

  • Mypy version used: 1.7.1.
  • Mypy command-line flags: see above
  • Mypy configuration options from mypy.ini (and other config files): none
  • Python version used: 3.12.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmypy got something wrong

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions