Skip to content
Snippets Groups Projects
Commit 4d090c91 authored by Daniel Hornung's avatar Daniel Hornung
Browse files

Merge branch 'f-remove-deprecated-parent' into 'dev'

F remove deprecated parent

See merge request !91
parents e3d8d8c4 6b9c08b8
No related branches found
No related tags found
2 merge requests!100WIP: Filling XLSX: Seems to be working.,!91F remove deprecated parent
Pipeline #49412 passed with warnings
...@@ -14,6 +14,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ...@@ -14,6 +14,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Removed ### ### Removed ###
* The deprecated `parent` keyword from the YAML datamodel specification. Use
`inherit_from_{obligatory|recommended|suggested}` instead.
### Fixed ### ### Fixed ###
### Security ### ### Security ###
......
...@@ -52,9 +52,7 @@ from linkahead.common.datatype import get_list_datatype ...@@ -52,9 +52,7 @@ from linkahead.common.datatype import get_list_datatype
from .data_model import CAOSDB_INTERNAL_PROPERTIES, DataModel from .data_model import CAOSDB_INTERNAL_PROPERTIES, DataModel
# Keywords which are allowed in data model descriptions. # Keywords which are allowed in data model descriptions.
KEYWORDS = ["parent", # deprecated, use inherit_from_* instead: KEYWORDS = ["importance",
# https://gitlab.com/caosdb/caosdb-advanced-user-tools/-/issues/36
"importance",
"datatype", # for example TEXT, INTEGER or REFERENCE "datatype", # for example TEXT, INTEGER or REFERENCE
"unit", "unit",
"description", "description",
...@@ -595,16 +593,6 @@ debug : bool, optional ...@@ -595,16 +593,6 @@ debug : bool, optional
self._inherit(name, prop, db.RECOMMENDED) self._inherit(name, prop, db.RECOMMENDED)
elif prop_name == "inherit_from_suggested": elif prop_name == "inherit_from_suggested":
self._inherit(name, prop, db.SUGGESTED) self._inherit(name, prop, db.SUGGESTED)
elif prop_name == "parent":
warn(
DeprecationWarning(
"The `parent` keyword is deprecated and will be "
"removed in a future version. Use "
"`inherit_from_{obligatory|recommended|suggested}` "
"instead."
)
)
self._inherit(name, prop, db.OBLIGATORY)
else: else:
raise ValueError("invalid keyword: {}".format(prop_name)) raise ValueError("invalid keyword: {}".format(prop_name))
......
...@@ -109,7 +109,6 @@ Keywords ...@@ -109,7 +109,6 @@ Keywords
added as parents, and all Properties with at least the importance ``XXX`` are inherited. For added as parents, and all Properties with at least the importance ``XXX`` are inherited. For
example, ``inherited_from_recommended`` will inherit all Properties of importance ``recommended`` example, ``inherited_from_recommended`` will inherit all Properties of importance ``recommended``
and ``obligatory``, but not ``suggested``. and ``obligatory``, but not ``suggested``.
- **parent**: Parent of this entity. Same as ``inherit_from_obligatory``. (*Deprecated*)
Usage Usage
===== =====
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
import unittest import unittest
from datetime import date from datetime import date
from tempfile import NamedTemporaryFile from tempfile import NamedTemporaryFile
from pytest import deprecated_call, raises, mark from pytest import raises, mark
import linkahead as db import linkahead as db
from caosadvancedtools.models.parser import (TwiceDefinedException, from caosadvancedtools.models.parser import (TwiceDefinedException,
...@@ -527,7 +527,7 @@ F: ...@@ -527,7 +527,7 @@ F:
def test_issue_36(): def test_issue_36():
"""Test whether the `parent` keyword is deprecated. """Test whether the `parent` keyword is removed.
See https://gitlab.com/caosdb/caosdb-advanced-user-tools/-/issues/36. See https://gitlab.com/caosdb/caosdb-advanced-user-tools/-/issues/36.
...@@ -550,17 +550,12 @@ R3: ...@@ -550,17 +550,12 @@ R3:
inherit_from_obligatory: inherit_from_obligatory:
- R1 - R1
""" """
with deprecated_call(): with raises(ValueError) as ve:
# Check whether this is actually deprecated # The keyword has been removed, so it should raise a regular ValueError.
model = parse_model_from_string(model_string) model = parse_model_from_string(model_string)
assert "R3" in model assert "invalid keyword" in str(ve.value)
r3 = model["R3"] assert "parent" in str(ve.value)
assert isinstance(r3, db.RecordType)
for par in ["R1", "R2"]:
# Until removal, both do the same
assert has_parent(r3, par)
assert r3.get_parent(par)._flags["inheritance"] == db.OBLIGATORY
def test_yaml_error(): def test_yaml_error():
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment