Skip to content

Commit

Permalink
🐛 Fix py config merger module list issue
Browse files Browse the repository at this point in the history
Apart from the already supported override:
```
[[tool.mypy.overrides]]
module = "some.module.name"
```

mypy also supports overringing multiple modules at once:
```
[[tool.mypy.overrides]]
module = ["some.module.name", "some.other.module.name"]
```

Made the non-list case into a list to have a uniform handling of it.
Also made it merge the different overrides of the same module.
  • Loading branch information
simonrainerson committed Oct 30, 2024
1 parent fa31f3f commit d21f4f5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Fixed
- Python's config merger now handles mypy overrides targeting multiple packages.

## [5.0.0] - 2024-10-15

### Added
Expand Down
12 changes: 6 additions & 6 deletions python/hooks/config-merger.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,12 @@ def mypy_overrides(config_file, key) -> dict:

root = {}
for override in overrides:
module_name = f'mypy-{override.pop("module")}'
root.update(
{
module_name: override,
}
)
modules = override.pop("module")
if not isinstance(modules, list):
modules = [modules]
for module in modules:
module_name = f'mypy-{module}'
root.setdefault(module_name, {}).update(override)
to_remove = config_file
for remove_key in keys[:-1]:
to_remove = to_remove.get(remove_key)
Expand Down

0 comments on commit d21f4f5

Please sign in to comment.