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

Deprecate optparse in favor of argparse #499

Merged
merged 2 commits into from Mar 17, 2020
Merged

Conversation

@sim-d
Copy link
Contributor

@sim-d sim-d commented Jan 1, 2020

According to the official docs, the optparse standard library has been deprecated since Python 3.2, in favor of the argparse standard library.

This pull request includes a commit that removes usage of optparse from pyflakes and uses argparse in its place. It also adds a couple of short descriptive strings for pyflakes usage via the command-line: a very brief one-liner describing pyflakes (taken from the README) and some information about the (optional) command-line arguments. Feel free to improve them, of course.

Note: this is my first fork, my first pull request, my first real usage of GitHub. I'm also relatively new to git and Python. Let me know if anything in my code or in the way I'm collaborating/etc. should be changed. I'm always trying to improve. (And happy new year!)

Copy link
Member

@asottile asottile left a comment

lg2m, thanks for the update!

@sim-d
Copy link
Contributor Author

@sim-d sim-d commented Jan 15, 2020

And it looks like pull requests are based off of branches, not commits... Adding my recent commit (for a separate issue--#505) to the deprecate_optparse branch seemed to update #499. Sorry if I should have created a new branch for #505! If needed (e.g. if #505 should not be supported), how would I go about "removing" that recent commit? I know I could make a new commit which essentially un-does the update for #505, but I'm not sure if that's the best practice.
(Still learning.)

@asottile
Copy link
Member

@asottile asottile commented Jan 15, 2020

ah, if you want to remove a commit you could do the following:

# make sure you're on the `deprecate_optparse` branch
git checkout deprecate_optparse
# *reset* back to the old commit
git reset --hard HEAD^  # here HEAD^ refers to the commit before the current revision, you could also explciitly use the exact hash
# then push this branch up -- note you need `--force` since you're erasing history
git push origin HEAD -f

in this case I think it's fine to keep the two commits together -- not sure how you'd do the second one without the first one (since it requires argparse features)

@sim-d
Copy link
Contributor Author

@sim-d sim-d commented Jan 15, 2020

Thanks! Yeah, the recent commit is certainly dependent upon the prior, though I probably should have created a new branch for it so as not to interfere with this PR. I'll leave them together for now, but would be happy to remove the recent commit if the change proposed by #505 (and now included in this PR) is not desired.

Copy link
Contributor

@bluetech bluetech left a comment

LGTM. For reference, Upgrading optparse code.

@asottile asottile merged commit ef3c5cb into PyCQA:master Mar 17, 2020
2 checks passed
2 checks passed
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants
You can’t perform that action at this time.