Skip to content

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

Merged
woile merged 1 commit into
masterfrom
fix-argparse-behavior-change
Sep 27, 2021
Merged

fix(cli): handle argparse different behavior after python 3.9#430
woile merged 1 commit into
masterfrom
fix-argparse-behavior-change

Conversation

@Lee-W

@Lee-WLee-W commented Sep 26, 2021

Copy link
Copy Markdown
Member

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 woileSeptember 26, 2021 08:14
@codecov

codecovBot commented Sep 26, 2021

Copy link
Copy Markdown

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 
FlagCoverage Δ
unittests97.90% <100.00%> (+<0.01%)⬆️

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

Impacted FilesCoverage Δ
commitizen/cli.py97.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 masterSep 27, 2021
@woile
woile deleted the fix-argparse-behavior-change branch September 27, 2021 06:40
@sarsharmasarsharma mentioned this pull request Sep 27, 2021
4 tasks
Sign up for freeto 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

@Lee-W@woile