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

argparse docs: normalize constant references #98765

Merged
merged 1 commit into from
Oct 28, 2022

Conversation

smontanaro
Copy link
Contributor

Second attempt. In the future, please give me the opportunity to respond to comments before summarily closing a PR. It just seems rude to me.

@bedevere-bot bedevere-bot added awaiting review docs Documentation in the Doc dir skip news labels Oct 27, 2022
@smontanaro
Copy link
Contributor Author

I am happy to respond to comments, but i can no longer push changes. What is going on?

@AlexWaygood
Copy link
Member

AlexWaygood commented Oct 27, 2022

I am happy to respond to comments, but i can no longer push changes. What is going on?

It might be that you made a change to the git branch using the GitHub website (perhaps by pressing the "Update branch" button), and then forgot to git pull locally (to update your local branch with the changes you made remotely) before you git pushed? That's a common problem everybody runs into :)

It's hard to diagnose without knowing what the precise error message you're getting is, though ;)

@smontanaro
Copy link
Contributor Author

Thanks @AlexWaygood. Here's what I'm seeing:

(python310) ~/src/python/cpython% git push origin HEAD
To github.com:smontanaro/cpython.git
 ! [rejected]              HEAD -> argparse-doc (non-fast-forward)
error: failed to push some refs to 'github.com:smontanaro/cpython.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

As far as I can tell from git pull, syncing smontanaro/cpython and git fetch upstream, I'm completely in sync, but I can't push. Part of my problem (at least by my way of thinking) is that it's telling me there's a problem, but doesn't give me a way to visualize it.

@AlexWaygood
Copy link
Member

AlexWaygood commented Oct 27, 2022

A bare git pull (not git pull upstream or anything line that, just git pull) usually works in situations like this. You need to synchronise the "argparse-doc" branch of your local clone of smontanaro/cpython with the "argparse-doc" branch of smontanaro/cpython as it exists on GitHub.

@CAM-Gerlach
Copy link
Member

If you don't have any local changes you want to keep, there's always the shotgun approach, resetting your local branch to what's on the remote branch:

git fetch origin
git reset --hard origin/argparse-doc

Then you can commit, push, etc. as before. If you do have any local changes, you can either cherry-pick or rebase them on top.

@smontanaro
Copy link
Contributor Author

I still have no idea how my local copy got weird w.r.t. the github version, but it's back in shape I think.

@CAM-Gerlach
Copy link
Member

CAM-Gerlach commented Oct 27, 2022

I'm still not entirely sure what actually happened on your end without having taken a look myself, but here are my tips to avoid this in the future and save both you time and heartache (and help reviewers too):

  • Take advantage of GitHub suggestions and avoid making local changes if not needed
  • If you do need to, apply suggestions and git pull before making local changes on an outstanding PR branch, and
  • Avoid updating your branch on GitHub if its not actually necessary (GitHub warns of a merge conflict, there's something specific you need to pull in, or you need to test code with the latest changes).

Copy link
Member

@CAM-Gerlach CAM-Gerlach left a comment

Choose a reason for hiding this comment

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

One small set of suggestions; other than that LGTM

Doc/library/argparse.rst Outdated Show resolved Hide resolved
Doc/library/argparse.rst Outdated Show resolved Hide resolved
@CAM-Gerlach
Copy link
Member

It seems things have gone wrong here again with the commit history due to another local merge—all the commits are duplicated twice. In addition, this is on top of (as was the case originally), the original changes were implemented, manually reverted and redone for unclear reasons, and the rework to remove the const changes, plus the repeated sets of suggestion applications, all of which makes the commit history here very hard to follow.

To fix all of this for now, you can just reset your branch to the latest merge with master and apply just the delta in the working tree as a new commit. To do so (tested locally to confirm):

git pull
git reset bded5edd9ab  # Last commit on main this has been merged with
git commit -am "Doc: Normalize constant references & link sys.stdin/stdout"
git push -f

Also, tip for the future: To avoid the time/effort, extra noise and CI resources of applying each suggestion individually, in the Files tab you can click Add to batch on each suggestion you want, then click Commit (adding an appropriately descriptive message) to commit them all in one go.

@smontanaro
Copy link
Contributor Author

I followed your advice on the reset etc stuff. Does it look okay now?

I'm not sure what you're referring to when you say "files" tab. I do everything from the command line on my laptop, so always work locally. I'll take a look though and see if i can figure out what you mean.

@smontanaro
Copy link
Contributor Author

Also, the GitHub app (at least on Android) seems to suck... Is it just me?

Copy link
Member

@CAM-Gerlach CAM-Gerlach left a comment

Choose a reason for hiding this comment

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

LGTM now @smontanaro , thanks!

@CAM-Gerlach
Copy link
Member

I followed your advice on the reset etc stuff. Does it look okay now?

Yup, looks great, thanks 👍

I'm not sure what you're referring to when you say "files" tab. I do everything from the command line on my laptop, so always work locally. I'll take a look though and see if i can figure out what you mean.

I do as well as far as Git is concerned, and also basic GitHub stuff with the hub CLI (there's also the newer gh CLI), but what I'm referring to is PR review suggestions in the GitHub web interface. When you apply review suggestions, as it appears you did for the ones on this review, instead of clicking the Commit button on each suggestion, entering a message (or leaving the generic one), and clicking Apply, you can instead go to the Files Changed tab on the PR, click Add to batch on each suggestion you want to apply, and then when you've clicked the button on all of the ones you want, you click the Commit button at the top or on each one, enter a descriptive message and then click Apply to commit them all in one go. See the docs for more details and screenshots.

Its no big deal if you do of course; I just wanted to mention the tip since a lot of devs aren't aware of that feature but it can save non-trivial time and effort especially with a larger number of suggestions.

Also, the GitHub app (at least on Android) seems to suck... Is it just me?

I've never used any apps for GitHub myself (either mobile or desktop) other than the hub CLI, and I've never logged into the GitHub web UI on mobile (just very occasional browsing/checking things), so I couldn't say—I'm pretty old school myself. But I haven't heard the best things about it from some of the other devs who do.

@smontanaro
Copy link
Contributor Author

smontanaro commented Oct 28, 2022 via email

@CAM-Gerlach
Copy link
Member

Sorry for all the trouble on this one!

@AlexWaygood AlexWaygood changed the title Argparse.rst - normalize constant references argparse docs: normalize constant references Oct 28, 2022
@AlexWaygood AlexWaygood merged commit b27b57c into python:main Oct 28, 2022
@miss-islington
Copy link
Contributor

Thanks @smontanaro for the PR, and @AlexWaygood for merging it 🌮🎉.. I'm working now to backport this PR to: 3.10, 3.11.
🐍🍒⛏🤖

@miss-islington
Copy link
Contributor

Sorry, @smontanaro and @AlexWaygood, I could not cleanly backport this to 3.10 due to a conflict.
Please backport using cherry_picker on command line.
cherry_picker b27b57c6e44a276c8a9843fd37d4cf65b2827d5c 3.10

@bedevere-bot
Copy link

GH-98807 is a backport of this pull request to the 3.11 branch.

@bedevere-bot bedevere-bot removed the needs backport to 3.11 only security fixes label Oct 28, 2022
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Oct 28, 2022
(cherry picked from commit b27b57c)

Co-authored-by: Skip Montanaro <skip.montanaro@gmail.com>
@bedevere-bot
Copy link

GH-98808 is a backport of this pull request to the 3.10 branch.

@bedevere-bot bedevere-bot removed the needs backport to 3.10 only security fixes label Oct 28, 2022
AlexWaygood pushed a commit to AlexWaygood/cpython that referenced this pull request Oct 28, 2022
miss-islington added a commit that referenced this pull request Oct 28, 2022
(cherry picked from commit b27b57c)

Co-authored-by: Skip Montanaro <skip.montanaro@gmail.com>
@AlexWaygood
Copy link
Member

Thanks, Skip!

AlexWaygood added a commit that referenced this pull request Oct 28, 2022
`argparse` docs: normalize constant references (#98765)

(cherry picked from commit b27b57c)

Co-authored-by: Skip Montanaro <skip.montanaro@gmail.com>
gvanrossum pushed a commit to gvanrossum/cpython that referenced this pull request Oct 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation in the Doc dir skip issue skip news
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants