Skip to content

Commit c71cc33

Browse files
committed
Fix the typing of sets in input and output
1 parent 6849f36 commit c71cc33

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

src/minizinc/CLI/driver.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import warnings
99
from datetime import timedelta
1010
from pathlib import Path
11-
from typing import Any, List, Optional, Type
11+
from typing import Any, List, Optional, Set, Type, Union
1212

1313
import minizinc
1414

@@ -33,6 +33,7 @@ def to_python_type(mzn_type: dict) -> Type:
3333
"""
3434
basetype = mzn_type["type"]
3535
pytype: Type
36+
# TODO: MiniZinc does not report enumerated types correctly
3637
if basetype == "bool":
3738
pytype = bool
3839
elif basetype == "float":
@@ -46,6 +47,12 @@ def to_python_type(mzn_type: dict) -> Type:
4647
)
4748
pytype = int
4849

50+
if mzn_type.get("set", False):
51+
if pytype is int:
52+
pytype = Union[Set[int], range]
53+
else:
54+
pytype = Set[pytype] # type: ignore
55+
4956
dim = mzn_type.get("dim", 0)
5057
while dim >= 1:
5158
# No typing support for n-dimensional typing

0 commit comments

Comments
 (0)