Skip to content
Snippets Groups Projects
Commit 64cb563b authored by florian's avatar florian
Browse files

FIX: Treat the specific case of type: [null, something]

parent 2640ac0e
No related branches found
No related tags found
2 merge requests!73MAINT: change wording of TableImporter argument and allow converters and...,!72Extend json-schema model parser
Pipeline #36029 passed
...@@ -139,7 +139,7 @@ unittest_py37: ...@@ -139,7 +139,7 @@ unittest_py37:
stage: unittest stage: unittest
image: python:3.7 image: python:3.7
script: &python_test_script script: &python_test_script
- pip install nose pandas pytest pytest-cov gitignore-parser openpyxl>=3.0.7 xlrd==1.2 h5py jsonref - pip install nose pandas pytest pytest-cov gitignore-parser openpyxl>=3.0.7 xlrd==1.2 h5py
- pip install git+https://gitlab.indiscale.com/caosdb/src/caosdb-pylib.git@dev - pip install git+https://gitlab.indiscale.com/caosdb/src/caosdb-pylib.git@dev
- pip install . - pip install .
- pytest --cov=caosadvancedtools unittests - pytest --cov=caosadvancedtools unittests
......
...@@ -156,6 +156,7 @@ def setup_package(): ...@@ -156,6 +156,7 @@ def setup_package():
author_email='h.tomwoerden@indiscale.com', author_email='h.tomwoerden@indiscale.com',
python_requires='>=3.7', python_requires='>=3.7',
install_requires=["caosdb>=0.11.0", install_requires=["caosdb>=0.11.0",
"jsonref",
"jsonschema>=4.4.0", "jsonschema>=4.4.0",
"numpy>=1.17.3", "numpy>=1.17.3",
"openpyxl>=3.0.7", "openpyxl>=3.0.7",
...@@ -164,7 +165,6 @@ def setup_package(): ...@@ -164,7 +165,6 @@ def setup_package():
], ],
extras_require={"h5-crawler": ["h5py>=3.3.0", ], extras_require={"h5-crawler": ["h5py>=3.3.0", ],
"gitignore-parser": ["gitignore-parser >=0.1.0", ], "gitignore-parser": ["gitignore-parser >=0.1.0", ],
"jsonref": ["jsonref", ],
}, },
packages=find_packages('src'), packages=find_packages('src'),
package_dir={'': 'src'}, package_dir={'': 'src'},
......
...@@ -747,6 +747,11 @@ class JsonSchemaParser(Parser): ...@@ -747,6 +747,11 @@ class JsonSchemaParser(Parser):
"be identified with CaosDB's name property." "be identified with CaosDB's name property."
) )
return None, force_list return None, force_list
# LinkAhead suports null for all types, so in the very special case of
# `"type": ["null", "<other_type>"]`, only consider the other type:
if isinstance(elt["type"], list) and len(elt["type"]) == 2 and "null" in elt["type"]:
elt["type"].remove("null")
elt["type"] = elt["type"][0]
if "enum" in elt: if "enum" in elt:
ent = self._treat_enum(elt, name) ent = self._treat_enum(elt, name)
elif elt["type"] in JSON_SCHEMA_ATOMIC_TYPES: elif elt["type"] in JSON_SCHEMA_ATOMIC_TYPES:
......
...@@ -12,7 +12,6 @@ deps=nose ...@@ -12,7 +12,6 @@ deps=nose
openpyxl >= 3.0.7 openpyxl >= 3.0.7
xlrd == 1.2 xlrd == 1.2
h5py h5py
jsonref
commands=py.test --cov=caosadvancedtools -vv {posargs} commands=py.test --cov=caosadvancedtools -vv {posargs}
[flake8] [flake8]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment