python / python/mypy

Cannot override `disallow_subclassing_any` for `matplotlib.*` in `pyproject.toml`

Open
#15,250 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug topic-configuration topic-disallow-any
Dominant language
Python
Stars
20.6k
Forks
3.3k
PR merge metrics
PR metrics pending

Description

Bug Report

I cannot override disallow_subclassing_any for matplotlib.* in pyproject.toml

To Reproduce

"""False-positive 'Class cannot subclass'."""
from matplotlib.backends.backend_qtagg import FigureCanvasQTAgg

class Class(FigureCanvasQTAgg):
    """Class."""

Expected Behavior

No error

Actual Behavior

bug.py:4: error: Class cannot subclass "FigureCanvasQTAgg" (has type "Any")  [misc]
Found 1 error in 1 file (checked 1 source file)

Your Environment

  • Mypy version used: mypy 1.3.0 (compiled: yes)
  • Mypy command-line flags: none
  • Mypy configuration options from mypy.ini (and other config files): see below
  • Python version used: 3.11.3

pyproject.toml

[tool.mypy]
ignore_missing_imports = false  # this works
disallow_subclassing_any = true # this works

[[tool.mypy.overrides]]
module = "matplotlib.*"
ignore_missing_imports = true    # this works
disallow_subclassing_any = false # this does not

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

Reproduce the false positive from the Python snippet and the shown pyproject.toml configuration using mypy 1.3.0. Trace how tool.mypy.overrides applies module-specific settings, then verify that disallow_subclassing_any = false for matplotlib.* suppresses the reported error while the global setting remains enabled.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 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.