Conversation

hasier

Fixes #9620

First and foremost, thanks to everyone that's working on maintaining and extending this project! 🙇 This is my first contribution here, hopefully a useful one.

I have been working in a monorepo project for a while and we have been trying to consolidate some of our configurations. I was coming from doing this with ruff, but I couldn't find a way for mypy to combine config files, when I found this comment. Seeing there was already an open discussion for it and a pointer in that direction, I thought I'd give it a go at updating the mypy behaviour.

I understand this might require a broader discussion regarding how this config extension/merge should happen, so I know this PR might not be the preferred option. Happy to contribute to the discussion however I can, but I thought it might be good to re-open the discussion with a (potential) solution in this PR.


if "mypy" not in parser:
if filename or os.path.basename(file_read) not in defaults.SHARED_CONFIG_NAMES:
print(f"{file_read}: No [mypy] section in config file", file=stderr)
else:
section = parser["mypy"]

extend = parser["mypy"].pop("extend", None)
Copy link
Author

@hasier hasier May 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[info] I thought about adding extend to the toml/ini templates above, but I was not sure of the way they might be used elsewhere, so it felt like doing something ad-hoc would be more suitable here. Happy to change it if there's another preferred way.

@github-actionsGitHub Actions

This comment has been minimized.

@github-actionsGitHub Actions

This comment has been minimized.

@github-actionsGitHub Actions

This comment has been minimized.

@github-actionsGitHub Actions

This comment has been minimized.

@github-actionsGitHub Actions

This comment has been minimized.

@github-actionsGitHub Actions

This comment has been minimized.

@github-actionsGitHub Actions

This comment has been minimized.

@github-actionsGitHub Actions

This comment has been minimized.

@github-actionsGitHub Actions

According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅

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

Successfully merging this pull request may close these issues.

Composing multiple configuration files
@hasier