-
-
Notifications
You must be signed in to change notification settings - Fork 937
Clarify Git.execute and Popen arguments #1688
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
b79198a
Document Git.execute parameters in definition order
EliahKagan 13e1593
Don't say Git.execute uses a shell, in its summary
EliahKagan 74b68e9
Copyedit Git.execute docstring
EliahKagan 133271b
Other copyediting in the git.cmd module
EliahKagan fc755da
Avoid having a local function seem to be a method
EliahKagan 2d1efdc
Test that git.cmd.execute_kwargs is correct
EliahKagan a8a43fe
Simplify shell test helper with with_exceptions=False
EliahKagan 9fa1cee
Extract a _assert_logged_for_popen method
EliahKagan 790a790
Log stdin arg as such, and test that this is done
EliahKagan c3fde7f
Log args in the order they are passed to Popen
EliahKagan ab95886
Eliminate istream_ok variable
EliahKagan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next
Next commit
Document Git.execute parameters in definition order
- Reorder the items in the git.cmd.Git.execute docstring that document its parameters, to be in the same order the parameters are actually defined in. - Use consistent spacing, by having a blank line between successive items that document parameters. Before, most of them were separated this way, but some of them were not. - Reorder the elements of execute_kwargs (which list all those parameters except the first parameter, command) to be listed in that order as well. These were mostly in order, but a couple were out of order. This is just about the order they appear in the definition, since sets in Python (unlike dicts) have no key order guarantees.
- Loading branch information
commit b79198a880982e6768fec4d0ef244338420efbdc
There are no files selected for viewing
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This changes only the order in which they are given, not the contents, and the set is equal to the same value as before.
However, I am wondering if
command
should actually be added here. Although the@overload
-decorated stubs forGit.execute
define some parameters as keyword-only, in the actual definition no parameter is keyword-only and there is definitional symmetry betweencommand
and the others. Should I worry about what happens if someone has agit-command
script that they can usually run asgit command
and tries to rung.command()
whereg
is agit.cmd.Git
instance? Or related situations?Another ramification of the parameters not being keyword-only is that, because they can be passed positionally, it is a breaking change to add a new one to
Git.execute
elsewhere than the end. Still, regarding #1686 (comment), if you think astdin
parameter should be added as a synonym ofistream
, this could still be done even withstdin
at the end, with the docstring items that document the parameters referring to each other to overcome any confusion. I am inclined to say the added complexity is not worthwhile (for example, the function would have to handle the case where they are both passed and with inconsistent values). But a possible argument against this is that thetext
synonym ofuniversal_newlines
could also be added.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In these situations it would be great to know why
command
was put there in the first place, and I for one do not remember. I know there never was an issue related tocommand
specifically, which seems to indicate it's a limitation worth ignoring or fixing in a non-breaking fashion (which seems possible).Regarding
istream
, I'd think maintaining stability would let me sleep better at night especially since you seem to agree that it's used consistently here and ingitdb
. Probably along with the documentation improvements, all is well and better than it was before, which even in the past didn't seem to have caused enough confusion to cause an issue to be opened.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean why it was omitted from the
execute_kwargs
set? If so, my guess is that it was intended to be used positionally while the others were intended to be keyword-only. This is judging by how they are given as keyword-only arguments in the@overload
s, where they are preceded by a*,
item in the list of formal parameters, which is absent in the actual function definition (thus causing them to accept both positional and keyword arguments).But it may be that I am misunderstanding what you mean here. It is also possible that their keyword-only status in the
@overload
s was intentionally different from the ultimate definition and intended to provide guidance. (I'm not sure. The@overload
s are missing most of the arguments, which confuses tooling and seems unintentional.)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am happy to adopt your conclusion in that this is not intentional and since there are negative side-effects, like tooling not working correctly, it's certainly something that could be improved.
If against all odds such an action does create downstream breakage, it could also be undone with a patch release.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we should make the parameters in the real definition actually keyword-only, since that is a breaking change. Or, at least, I would not rush to that. It seems likely to me that, at least for the first few, people are passing them positionally.
I believe it is merely the absence of many parameters from the
@overload
-decorated stubs (which precede the real definition) that is causing VS Code not to show or autocomplete some arguments. Adding the missing parameters to the@overload
-decorated stubs should be sufficient to fix that, and it shouldn't be a breaking change because (a) they are just type stubs, so it doesn't break runtime behavior, (b) the actual change seems compatible even relative to what the type stubs said before, and (c) GitPython doesn't have static typing stability currently anyway, because althoughpy.typed
is included in the package,mypy
checks don't pass (nor, per #1659, dopyright
checks pass).