trevorld / r-argparse

command-line optional and positional argument parser
GNU General Public License v2.0
103 stars 11 forks source link

Extraneous error message in usage output with python v3.10 #36

Closed dariober closed 2 years ago

dariober commented 2 years ago

Option -h/--help gives a parse error when using python 3.10. It doesn't happen with python 3.9. This is with the latest R and r-argparse (2.1.1) installed via conda/mamba in a fresh environment.

This is a minimal script, test.R:

#!/usr/bin/env Rscript

library(argparse)

parser <- ArgumentParser()
args <- parser$parse_args()

Using python 3.9, installation:

mamba install 'r-base>=4.1' 'r-argparse>=2.1' 'python=3.9'

python --version
Python 3.9.7

R --version
R version 4.1.1 (2021-08-10) -- "Kick Things"
Copyright (C) 2021 The R Foundation for Statistical Computing
Platform: x86_64-conda-linux-gnu (64-bit)

All good:

./test.R -h
usage: ./test.R [-h]

optional arguments:
  -h, --help  show this help message and exit

echo $?
0

Now python 3.10:

mamba install 'r-base>=4.1' 'r-argparse>=2.1' 'python>=3.10'

python --version
Python 3.10.0

R --version
R version 4.1.1 (2021-08-10) -- "Kick Things"
Copyright (C) 2021 The R Foundation for Statistical Computing
Platform: x86_64-conda-linux-gnu (64-bit)

gives parse error:

./test.R -h
Error in .stop(output, "parse error:") : parse error:
usage: ./test.R [-h]

options:
  -h, --help  show this help message and exit
Calls: <Anonymous> -> parse_args_output -> .stop
Execution halted

echo $?
1

Other than this, it seems to work but it would be nice to fix!

trevorld commented 2 years ago