Skip to content

Commit af3ec06

Browse files
committed
fixing parameter type errors
2 parents c04f379 + 5a69500 commit af3ec06

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

packages/schema_wrapper/src/generate_schema_wrapper.py

+15-4
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from pathlib import Path
1212
from urllib import request
1313
import graphlib
14-
from .utils import get_valid_identifier, get_key_by_value, get_dependencies
14+
from utils import get_valid_identifier, get_key_by_value, get_dependencies
1515

1616
sys.path.insert(0, str(Path.cwd()))
1717

@@ -58,7 +58,13 @@ def generate_class(class_name: str, class_schema: Dict[str, Any]) -> str:
5858
optional_params = []
5959

6060
# Ensuring all the property names are valid Python identifiers
61+
<<<<<<< HEAD
6162
valid_properties = {}
63+
=======
64+
valid_property_keys = map(get_valid_identifier, properties.keys())
65+
properties = dict(zip(valid_property_keys, properties.values()))
66+
67+
>>>>>>> 5a69500f83ddf4e842161bbf7cac73e6d3a32621
6268
for prop, prop_schema in properties.items():
6369
valid_prop = get_valid_identifier(prop)
6470
valid_properties[valid_prop] = prop_schema
@@ -121,7 +127,11 @@ def get_type_hint(type_schema: Dict[str, Any]) -> str:
121127
return f"List[{datatype}]"
122128

123129
if 'type' in type_schema:
130+
<<<<<<< HEAD
124131
if isinstance(type_schema['type'], list):
132+
=======
133+
if not isinstance(type_schema['type'], str) and isinstance(type_schema['type'], Iterable):
134+
>>>>>>> 5a69500f83ddf4e842161bbf7cac73e6d3a32621
125135
types = []
126136
for t in type_schema['type']:
127137
datatype = KNOWN_PRIMITIVES.get(t)
@@ -137,6 +147,10 @@ def get_type_hint(type_schema: Dict[str, Any]) -> str:
137147
return 'Any'
138148
return datatype
139149
elif 'anyOf' in type_schema:
150+
<<<<<<< HEAD
151+
=======
152+
assert isinstance(type_schema['anyOf'], list)
153+
>>>>>>> 5a69500f83ddf4e842161bbf7cac73e6d3a32621
140154
types = [get_type_hint(option) for option in type_schema['anyOf']]
141155
return get_type_union(types)
142156
elif '$ref' in type_schema:
@@ -156,9 +170,6 @@ def generate_schema_wrapper(schema_file: Path, output_file: Path) -> str:
156170
rootschema_definitions = rootschema.get("definitions", {})
157171
ts = graphlib.TopologicalSorter()
158172

159-
# if not output_file.parent.exists():
160-
# output_file.parent.mkdir(parents=True, exist_ok=True)
161-
162173
for name, schema in rootschema_definitions.items():
163174
dependencies = get_dependencies(schema)
164175
if dependencies:

0 commit comments

Comments
 (0)