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

Break up arguments section #2586

Merged
merged 15 commits into from
Dec 5, 2024
Merged

Conversation

Rowlando13
Copy link
Collaborator

@Rowlando13 Rowlando13 commented Aug 14, 2023

Break up the arguments section into arguments and handling files.

@Rowlando13 Rowlando13 marked this pull request as draft August 14, 2023 07:37
@davidism davidism added the docs label Sep 1, 2023
Like options, arguments can also grab values from an environment variable.
Unlike options, however, this is only supported for explicitly named
environment variables.
This feature is not recommended since it be confusing to users. Arguments can only pull environment variables from ? explicitly named environment variables. In that case, it can also be a list of different environment variables where the first one is picked. ?
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@AndreasBackx Do you know what the documentation could mean in this section? I have not a clue so providing clearer wording and a better example is difficult.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not sure myself, I'd have to look in the code. I'd have a look around the implementation or look at the blame of that documentation, maybe the commit/PR introducing it has some history.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@AndreasBackx I think actually only Armin knew. It was basically unchanged since the first commit. But I figured it out by playing around. Could you give this PR a once over?

@Rowlando13 Rowlando13 marked this pull request as ready for review November 14, 2024 02:25
Copy link
Collaborator

@AndreasBackx AndreasBackx left a comment

Choose a reason for hiding this comment

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

What I really like about these changes is that some of this new documentation is so much more easily skimmable. Instead of rather large paragaphs, we have easy to understand lists. I am a big fan of this and we should to this elsewhere in the documentation as well!

Most of my comments are improvements towards:

  1. Consistency in writing.
  2. Adding typing which aids with what we're documenting here.
  3. Some regressions I think we're making somewhere.

File open behavior can be controlled by the boolean kwarg ``lazy``. If a file is opened lazily:

* A failure at first IO operation will happen by raising an :exc:`FileError`.
* It can help minimize resource handling confusion. If a file is opened in lazy mode, it will receive a ``close_intelligently`` method that can help figure out if the file needs closing or not. This is not needed for parameters, but is necessary for manually prompting. For manual prompts with the :func:`prompt` function you do not know if a stream like stdout was opened (which was already open before) or a real file was opened (that needs closing).
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we have a page anywhere where close_intelligently is documented? Would be nice to link to it because this does not explain that enough imho.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I agree it does not explain enough. It seems like it refers to specific parts of the code but I am not sure which.

Copy link
Collaborator

Choose a reason for hiding this comment

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

It refers to LazyFile.close_intelligently. Could you add that reference? That should be good for now. LazyFile is in utils.

@Rowlando13
Copy link
Collaborator Author

Was not able to include full type hints because of issues with custom sphinx directive we use to run the code.

@Rowlando13 Rowlando13 merged commit 8e7bed0 into pallets:stable Dec 5, 2024
12 checks passed
@Rowlando13 Rowlando13 deleted the trim_args_section branch December 5, 2024 07:13
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 20, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants