Skip to content
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

deeply merge_configs #89

Merged
merged 13 commits into from
Feb 3, 2022
Merged

deeply merge_configs #89

merged 13 commits into from
Feb 3, 2022

Conversation

Jasha10
Copy link
Contributor

@Jasha10 Jasha10 commented Jan 29, 2022

Implement deep (recursive) merging for nested configs.

Closes #88.

@Jasha10 Jasha10 marked this pull request as ready for review January 29, 2022 22:35
Copy link
Owner

@dbatten5 dbatten5 left a comment

Choose a reason for hiding this comment

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

looks good, thanks for pr @Jasha10. a few little comments to address and a failing ci

src/maison/config.py Outdated Show resolved Hide resolved
Copy link
Owner

@dbatten5 dbatten5 left a comment

Choose a reason for hiding this comment

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

almost there, couple pesky flake8 things to fix. did you enable the pre-commit hooks with pre-commit install?

src/maison/config.py Outdated Show resolved Hide resolved
src/maison/utils.py Outdated Show resolved Hide resolved
Comment on lines 125 to 127
RuntimeError: A dict cannot be merged on top of a non-dict.
For example, the following would fail:
`deep_merge({"foo": "bar"}, {"foo": {"baz": "qux"}})`
Copy link
Owner

Choose a reason for hiding this comment

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

some indentation issues here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure how to fix this. I can't get flake8 to pass no matter what I do.

Copy link
Owner

Choose a reason for hiding this comment

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

looks like these two lines just need two more spaces of indentation?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That does the trick! Done in 510faa7.

Copy link
Owner

Choose a reason for hiding this comment

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

great! one final hurdle is the coverage which i think could be sorted by adding a test to cover that RuntimeError. sorry i know this ci is quite strict

Comment on lines 142 to 147
param(
{1: 2, 2: 5},
{1: {3: 4}},
raises(RuntimeError),
id="merge-dict-into-scalar",
),
Copy link
Owner

@dbatten5 dbatten5 Feb 3, 2022

Choose a reason for hiding this comment

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

thanks for adding this extra bit of coverage. how would you feel about moving this to a separate test? i think it would make the tests more readable and would also mean you don't have to import the RaisesContext from the private _pytest api

Copy link
Contributor Author

@Jasha10 Jasha10 Feb 3, 2022

Choose a reason for hiding this comment

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

Done in 681d47d.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, whoops, I misunderstood you.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated in 72d00b3.

@Jasha10 Jasha10 requested a review from dbatten5 February 3, 2022 11:50
@dbatten5
Copy link
Owner

dbatten5 commented Feb 3, 2022

perfect! thanks so much @Jasha10 , great addition. will get a release done shortly

@dbatten5 dbatten5 merged commit 351f787 into dbatten5:main Feb 3, 2022
@Jasha10 Jasha10 deleted the recursive-merge branch February 3, 2022 18:08
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.

Feature request: deeply merge_configs
2 participants