Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Move mypy configuration into pyproject.toml
Browse files Browse the repository at this point in the history
This is mainly to take advantage of the significantly more convenient
syntax for module overrides. For example, instead of:

    [mypy-synapse.api.*]
    disallow_untyped_defs = True

    [mypy-synapse.app.*]
    disallow_untyped_defs = True

    [mypy-synapse.crypto.*]
    disallow_untyped_defs = True

The pyproject.toml file allows:

    [[tool.mypy.overrides]]
    module = [
        "synapse.api.*",
        "synapse.app.*",
        "synapse.crypto.*",
    ]
    disallow_untyped_defs = true

Not a huge difference with two or three modules, but we list many more.

This is especially important as I'm about to set disallow_untyped_defs
at the global level and provide module-level opt-outs so that we require
typed definitions in all newly added code.

Switching to this format will save several hundred lines of repetitive
boilerplate and clarify the intent of each stanza.

It's also easier to keep things ordered, since it works to just pipe a
region to `sort`, while mypy.ini requires handling a 3-line structure.
Ordering helps keep these settings synced up with the files on disk.

Signed-off-by: Dan Callahan <danc@element.io>
  • Loading branch information
callahad committed Nov 11, 2021
1 parent c99da2d commit d435e9c
Show file tree
Hide file tree
Showing 3 changed files with 251 additions and 384 deletions.
1 change: 1 addition & 0 deletions changelog.d/11315.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Port mypy.ini into pyproject.toml.
384 changes: 0 additions & 384 deletions mypy.ini

This file was deleted.

Loading

0 comments on commit d435e9c

Please # to comment.