Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Add config key to extend config files #19135

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 11 commits into
base: master
Choose a base branch
Loading
from

Conversation

hasier
Copy link

@hasier hasier commented May 23, 2025

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.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

Copy link
Contributor

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 GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Composing multiple configuration files
1 participant
Morty Proxy This is a proxified and sanitized view of the page, visit original site.