Skip to content

Commit

Permalink
Merge pull request #180 from Vincent-lau/variant-cmdparse
Browse files Browse the repository at this point in the history
Fix python cmdline parser for variants
  • Loading branch information
edwintorok authored Sep 25, 2024
2 parents bdd3ab5 + 31dac5b commit d558f6a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ jobs:
matrix:
# windows-latest async does not support it for now
operating-system: [macos-latest, ubuntu-latest]
ocaml-version: [ '4.14.0', '4.08.1' ]
ocaml-version: [ '5.2.0', '4.14.0' ]
steps:
- uses: actions/checkout@master
- name: Setup Python
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Cache pip
Expand All @@ -29,7 +29,7 @@ jobs:
- name: Install Python dependencies
run: pip install pylint pycodestyle
- name: Install OCaml
uses: ocaml/setup-ocaml@v2
uses: ocaml/setup-ocaml@v3
with:
ocaml-compiler: ${{ matrix.ocaml-version }}
- name: Install OCaml dependencies
Expand Down
6 changes: 4 additions & 2 deletions src/lib/pythongen.ml
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,9 @@ class ListAction(argparse.Action):

let compat_block =
[ Line "get_str = str"
; Line "if sys.version_info[0] > 2:"
; Block [ Line "long = int"; Line "unicode = str"; Line "str = bytes" ]
; Line "long = int"
; Line "unicode = str"
; Line "str = bytes"
; Line ""
]

Expand Down Expand Up @@ -699,6 +700,7 @@ let commandline_parse _ (BoxedFunction m) =
| Basic Int32 -> ", type=int"
| Basic Bool -> ", type=lambda x: json.loads(x.lower())"
| Basic Float -> ", type=float"
| Variant _ -> ", type=json.loads"
| _ -> "")))
inputs
@ [ Line "return vars(parser.parse_args())" ])
Expand Down

0 comments on commit d558f6a

Please sign in to comment.