Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion TODO.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
- (!) README.md
- Do not use OrderedDict (dictionaries in Python 3.7 are now ordered)
- Docstrings
- Features
- Models layer
- [X] Data variant converting
- [X] Change empty dict to actual dict type, not empty models
- [X] Data variant merging
- [X] Create and register models
- [X] Merge meta-models and extract common ones
- [ ] Strict mode
- [X] Save meta-models as python code
- [X] typing code generation
- [ ] (Maybe in future) Extract to another module (by serializers for each dynamic typing class)
Expand Down
5 changes: 2 additions & 3 deletions json_to_models/dynamic_typing/typing.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import operator
from collections import OrderedDict
from inspect import isclass
from typing import Dict, Set, Tuple

Expand Down Expand Up @@ -28,7 +27,7 @@ def compile_imports(imports: ImportPathList) -> str:
"""
Merge list of imports path and convert them into list code (string)
"""
class_imports_map: Dict[str, Set[str]] = OrderedDict()
class_imports_map: Dict[str, Set[str]] = {}
package_imports_set: Set[str] = set()
for module, classes in filter(None, imports):
if classes is None:
Expand All @@ -42,7 +41,7 @@ def compile_imports(imports: ImportPathList) -> str:
class_imports_map[module] = classes_set

# Sort imports by package name and sort class names of each import
class_imports_map = OrderedDict(sorted(
class_imports_map = dict(sorted(
((module, sorted(classes)) for module, classes in class_imports_map.items()),
key=operator.itemgetter(0)
))
Expand Down
5 changes: 2 additions & 3 deletions json_to_models/generator.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import re
from collections import OrderedDict
from typing import Any, Callable, List, Optional, Pattern, Union

from unidecode import unidecode
Expand Down Expand Up @@ -114,7 +113,7 @@ def merge_field_sets(self, field_sets: List[MetaData]) -> MetaData:
"""
Merge fields sets into one set of pairs (key, metadata)
"""
fields: dict = OrderedDict()
fields: dict = {}

first = True
for model in field_sets:
Expand Down Expand Up @@ -166,7 +165,7 @@ def optimize_type(self, meta: MetaData, process_model_ptr=False) -> MetaData:
Default is False to prevent recursion cycles.
"""
if isinstance(meta, dict):
fields = OrderedDict()
fields = {}

for k, v in meta.items():
fields[k] = self.optimize_type(v)
Expand Down
4 changes: 2 additions & 2 deletions json_to_models/registry.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from collections import OrderedDict, defaultdict
from collections import defaultdict
from itertools import chain, combinations
from typing import Dict, Iterable, List, Set, Tuple

Expand Down Expand Up @@ -50,7 +50,7 @@ def __init__(self, *models_cmp: ModelCmp):
:param models_cmp: list of model comparators. If you want merge only equals models pass ModelFieldsEquals()
"""
self._models_cmp = models_cmp or self.DEFAULT_MODELS_CMP
self._registry: Dict[str, ModelMeta] = OrderedDict()
self._registry: Dict[str, ModelMeta] = {}
self._index = Index()

@property
Expand Down