Skip to content

Commit

Permalink
Merge pull request #220 from Dessia-tech/fix/typings
Browse files Browse the repository at this point in the history
fix(jsonschema): Typing Any does not raise error with subclass anymore
  • Loading branch information
masfaraud committed Apr 14, 2022
2 parents 71365f1 + ae9d2af commit 4227020
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

### Fixed
- Any typing does not trigger error with subclass anymore

## v0.7.0

### Fixed
Expand Down
7 changes: 2 additions & 5 deletions dessia_common/utils/jsonschema.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,8 @@ def jsonschema_from_annotation(annotation, jsonschema_element, order, editable=N
'type': 'object', 'is_class': True,
'properties': {'name': {'type': 'string'}}
})
elif typing_ is Any:
jsonschema_element[key].update({'type': 'object', 'properties': {'.*': '.*'}})
elif inspect.isclass(typing_) and issubclass(typing_, Measure):
ann = (key, float)
jsonschema_element = jsonschema_from_annotation(
Expand All @@ -237,11 +239,6 @@ def jsonschema_from_annotation(annotation, jsonschema_element, order, editable=N
jsonschema_element[key]['units'] = typing_.units
elif typing_ in [TextIO, BinaryIO] or issubclass(typing_, (BinaryFile, StringFile)):
jsonschema_element[key].update({'type': 'text', 'is_file': True})
elif typing_ is Any:
jsonschema_element[key].update({
'type': 'object',
'properties': {'.*': '.*'}
})
else:
classname = dc.full_classname(object_=typing_, compute_for='class')
if inspect.isclass(typing_) and issubclass(typing_, dc.DessiaObject):
Expand Down

0 comments on commit 4227020

Please sign in to comment.