Skip to content

Overlapping modules overloads in pyproject.toml result in undefined behavior #19314

Open
@stephenfin

Description

@stephenfin

Bug Report

It's unclear from the docs and runtime what the expected behavior is if you define multiple [[tool.mypy.overrides]] with overlapping modules.

To Reproduce

[[tool.mypy.overrides]]
module = [
    "openstack._log",
    "openstack.cloud._baremetal",
    "openstack.common",
    "openstack.common.*",
    "openstack.config",
    "openstack.config.*",
    "openstack.connection",
    "openstack.exceptions",
    "openstack.fields",
    "openstack.format",
    "openstack.proxy",
    "openstack.utils",
    "openstack.version",
    "openstack.warnings",
]
warn_return_any = true
disallow_untyped_decorators = true
disallow_any_generics = true
disallow_subclassing_any = true
disallow_untyped_calls = true
disallow_untyped_defs = true
no_implicit_reexport = true

[[tool.mypy.overrides]]
module = [
    "openstack.cloud._baremetal",
]
# unset 'warn_return_any' since we need to type the proxy classes first
warn_return_any = false

Expected Behavior

I would expect the configuration to layer, with later (in the file) configuration overriding earlier configuration.

Actual Behavior

In my instance, later configuration related to unit tests was ignored. I have no investigated what's happening here though.

Your Environment

  • Mypy version used: mypy 1.16.1
  • Mypy command-line flags: none
  • Mypy configuration options from mypy.ini (and other config files): per above
  • Python version used: python 3.13.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmypy got something wrongtopic-configurationConfiguration files and flags

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions