-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Move mypy configuration into pyproject.toml #11315
Conversation
Split out from #11302 |
cc: @clokep 👋 Understanding your objections about independent tools Voltron-ing themselves into pyproject.toml, but (a) it seems to be a clear part of the current zeitgeist, so limited gains from being contrarian while there are maintenance gains at least for the duration of our mypy-improvement sprint, and (b) once we get things slimmed down to where the mypy config is just couple dozen lines, we can move back to mypy.ini if we really want to. |
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 <[email protected]>
1277f6b
to
d435e9c
Compare
Comparison between next steps with pyproject.toml and mypy.ini at https://gist.github.com/callahad/596d9e264f08179dcc2b1997ef8ce375
|
#11322 aims to cut this down quite a bit. As far as I can tell we only need to add ~10 more to get the entire code-base covered. The big stopping point would be
I don't understand this part. Ordering isn't a huge deal when we're adding individual lines?
I do not agree, I think this is really a preference thing and not a clear-cut movement.
This sounds to me like churn for a small benefit for a small period of time. I'm not going to block this PR, but I do not agree it is an improvement. |
Personally I like the TOML syntax more than the weird INI variant that Python tools seem to use, though I do also like single-use files (especially because seeing Further, multi-module overrides in standard syntax seem to be specified like With the above said, I would personally prefer what Dan is suggesting. That said, if someone feels quite against dropping (the 3-line stanzas would be OK imo, noisy but since our job is to remove them rather than think about adding new ones, it would certainly be an improvement) |
My read on the situation is that Clokep is skeptical of the value of pyproject.toml, but not so opposed as to block it. Reivilibre is generally positive toward the proposal, but wishes mypy supported TOML syntax in a standalone file. As the proposer, I'm naturally in favor of this pull request. In the absence of someone raising a blocking objection, I'd like to request a review with a goal of merging by end of day. This will bitrot quickly as work is done in typing, and the specific implementation here is highly constrained: it's either our current mypy.ini or this pyproject.toml. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm going to trust @callahad that the two sets of config are equivalent, and consider the spirit of the PR rather than the letter of it.
Broadly, I have no strong opinion on whether we put stuff in mypy.ini
or pyproject.toml
; I think there is for and against for both systems. If @callahad is keen, I'll not stand in his way.
Better fix up the conflict though :/
@@ -0,0 +1 @@ | |||
Port mypy.ini into pyproject.toml. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Port mypy.ini into pyproject.toml. | |
Move mypy configuration settings into `pyproject.toml`. |
Yes, I'd say I'm a -0.5 on it, if you'd like me to use that system. 😄 |
I'm going to close this since it has bitrotted. We can re-do this in the future if we want. |
This is mainly to take advantage of the significantly more convenient
syntax for module overrides. For example, instead of:
The pyproject.toml file allows:
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 [email protected]
Pull Request Checklist
EventStore
toEventWorkerStore
.".code blocks
.(run the linters)