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

fix(cli): handle argparse different behavior after python 3.9 #430

Merged
merged 1 commit into from
Sep 27, 2021

Conversation

Lee-W
Copy link
Member

@Lee-W Lee-W commented Sep 26, 2021

Description

argparse raises TypeError when non exist command is provided on Python < 3.9
but raise SystemExit with exit code == 2 on Python 3.9
this error does not break anything obviously from the user perspective, but will break our existing test

#429

This issue is caused by https://bugs.python.org/issue29298. The new checking is the correct one, but we'll need to keep the old one for backward compatibility. This fix was first introduced on 3.9.7 👉 see argparse.py#L730-L731

Checklist

  • Add test cases to all the changes you introduce
  • Run ./script/format and ./script/test locally to ensure this change passes linter check and test
  • Test the changes on the local machine manually
  • Update the documentation for the changes

Expected behavior

detailed on #429

Steps to Test This Pull Request

detailed on #429

Additional context

argparse raises TypeError when non exist command is provided on Python < 3.9
but raise SystemExit with exit code == 2 on Python 3.9
this error does not break anything obviously from the user perspective, but will break our existing test

429
@Lee-W Lee-W requested a review from woile September 26, 2021 08:14
@codecov
Copy link

codecov bot commented Sep 26, 2021

Codecov Report

Merging #430 (ca0e4bc) into master (9924180) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #430   +/-   ##
=======================================
  Coverage   97.90%   97.90%           
=======================================
  Files          39       39           
  Lines        1382     1384    +2     
=======================================
+ Hits         1353     1355    +2     
  Misses         29       29           
Flag Coverage Δ
unittests 97.90% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
commitizen/cli.py 97.61% <100.00%> (+0.11%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d09c085...ca0e4bc. Read the comment docs.

@Lee-W Lee-W marked this pull request as draft September 26, 2021 08:44
@Lee-W Lee-W marked this pull request as ready for review September 26, 2021 11:34
@woile woile merged commit a06f3b1 into master Sep 27, 2021
@woile woile deleted the fix-argparse-behavior-change branch September 27, 2021 06:40
@sarsharma sarsharma mentioned this pull request Sep 27, 2021
4 tasks
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