Skip to content

Permit configuration via a stand-alone TOML file (mypy.toml) #18617

Open

Description

@AA-Turner

Feature

In #5205, MyPy gained support for declaring configuration in the TOML format, but only in pyproject.toml. I propose supporting configuration via a stand-alone TOML document, such as mypy.toml or .mypy.toml.

Pitch

This parallels, and perhaps would eventually replace, configuration via mypy.ini. This is most useful when checking non-project code, such as in Python (python/cpython#129708), where we have several distinct mypy.ini files to support type-checking different directories of a larger project. It may be useful for mono-repo layouts, where again the use of pyproject.toml is undesirable. Finally, this would be useful to keep tool configuration to independent files — in the Sphinx project, there are several hundred lines of mypy configuration in pyproject.toml, dominating the content of the file.

A

Activity

  1. Avasam commented on Feb 19, 2025

    @Avasam
    SponsorContributor

    The .ini format also has its limitations. Like not supporting comments at the end of a line and a weird exclude.

    Additional benefits includes: a single toml formatter (rather than needing an ini formatter just for this config). And IntelliSense could be provided through a schema.

  2. michael-pplx commented on Sep 10, 2025

    @michael-pplx

    [[mypy.overrides]] sections with long module = [...] lists are painful to migrate to mypy.ini which requires stuffing what were nicely formatted, multi-line lists into a long, comma-separated messes.

  3. michael-pplx commented on Sep 10, 2025

    @michael-pplx

    Note that explicitly calling mypy --config-file=.mypy.toml does work

  4. ofek commented on Nov 11, 2025

    @ofek
    Sponsor

    I would really love this capability, especially the .mypy.toml variant.

  5. edgarrmondragon commented on Apr 21, 2026

    @edgarrmondragon
    Contributor

    There's a PR which seems to be in a good state:

    I'm curious what the maintainers think of this feature request.

  6. JelleZijlstra commented on Apr 22, 2026

    @JelleZijlstra
    Member

    Personally I'm not enthusiastic about adding yet another configuration file. Having more configuration files means the config system is more complex to understand as users need to think about the precedence between all these different files.

  7. Avasam commented on Apr 22, 2026

    @Avasam
    SponsorContributor

    I don't really see a reason for mypy.ini and mypy.toml to coexist in the same folder.
    If multiple non-pyproject mypy config files are detected, I don't mind erroring out and sidestepping the precedence issue entirely.


    I personally do prefer mypy's toml configuration format. But I'm still using mypy.ini instead of pyproject.toml because I don't like shoving all tooling config in a single file. Makes it much harder to template/cookie-cutter. Or find from an ide file search.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions