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

Add option to prevent config files from writing #246

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Erotemic
Copy link

I have a use case where I need to call parse_known_args to finish the contruction of my ArgumentParser instance. Thus, I don't want it to just write the config and exit. This PR adds a flag ignore_write_args to the parse_known_args method. When True, this prevents the config files from running.

If this change is desired, please advise on any additional change that would need to be made to support this feature (places where to change the docs / etc).

(My editor also removed whitespace, I can undo that the maintainers would like to keep the diff minimal)

if getattr(a, "is_write_out_config_file_arg", False)]
output_file_paths = [a for a in output_file_paths if a is not None]
self.write_config_file(namespace, output_file_paths, exit_after=True)
if ignore_write_args:
Copy link
Owner

Choose a reason for hiding this comment

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

I think this should be if not ignore_write_args:

@@ -480,6 +480,7 @@ def parse_known_args(
config_file_contents=None,
env_vars=os.environ,
ignore_help_args=False,
ignore_write_args=False,
Copy link
Owner

Choose a reason for hiding this comment

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

I think this should be named
ignore_write_out_config_file_args

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.

2 participants