feat: allow config in command decorator#4
Open
Thomzoy wants to merge 1 commit into
Open
Conversation
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## main #4 +/- ##
==========================================
+ Coverage 97.82% 97.86% +0.03%
==========================================
Files 8 8
Lines 644 655 +11
==========================================
+ Hits 630 641 +11
Misses 14 14
☔ View full report in Codecov by Sentry. |
c595e44 to
9d0f007
Compare
6c07215 to
08ac9fe
Compare
percevalw
reviewed
Aug 29, 2023
Comment on lines
+112
to
131
| if initial_config is not None: | ||
| initial_configs = ( | ||
| [initial_config] | ||
| if isinstance(initial_config, Config) | ||
| else initial_config | ||
| ) | ||
|
|
||
| initial_config_path = [] | ||
|
|
||
| for c in initial_configs: | ||
| temp_file = tempfile.NamedTemporaryFile(delete=False) | ||
| temp_file.write( | ||
| c.to_str().encode() | ||
| ) # Write the string to the file | ||
| temp_file.close() | ||
| initial_config_path.append(Path(temp_file.name)) | ||
| config_path = initial_config_path + config_path | ||
|
|
||
| if config_path: | ||
| config, name_from_file = merge_from_disk(config_path) |
Member
There was a problem hiding this comment.
I feel the disk writing operation is not really necessary, if its only purpose is to use merge_from_disk. Could we drop merge_from_disk, load all configs and merge them directly from memory instead ?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The goal of this PR is to add an
configargument in@app.command. As such, it allows to pass one (or more)Configobject to the underlying script. All additional configurations provided through the CLI will still be used via merging.Then
python -m script.pywill run as isChecklist