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
2 changes: 1 addition & 1 deletion doc/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pandas >=0.20
matplotlib
tables # ==pytables
openpyxl
pydantic >=2.12
pydantic ==2.12

# dependencies to actually build the documentation
sphinx ==5.3.0
Expand Down
2 changes: 1 addition & 1 deletion doc/source/changes/version_0_35.rst.inc
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Backward incompatible changes
is closed by the user. To revert to the previous behavior, use show=False.

* Using :py:obj:`CheckedSession`, :py:obj:`CheckedParameters` or
:py:obj:`CheckedArray` now requires installing pydantic >= 2.12
:py:obj:`CheckedArray` now requires installing pydantic >= 2
(closes :issue:`1075`).


Expand Down
2 changes: 1 addition & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ dependencies:
- openpyxl
- xlsxwriter
- pytest >=6
- pydantic >= 2.12
- pydantic >=2
308 changes: 146 additions & 162 deletions larray/core/checked.py

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions larray/tests/test_checked_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,8 @@ def test_setitem_cs(checkedsession):
"Input should be an instance of Axis. Got input value of type 'int'."):
cs['a'] = 0
# -> CheckedArray
# with must_raise(TypeError, msg="Error while assigning value to variable 'h':\n"
# "Input should be an instance of Array. Got input value of type 'ndarray'."):
with must_raise(TypeError, msg="Expected object of type 'Array' or a scalar for the variable 'h' but got "
"object of type 'ndarray'"):
cs['h'] = h.data
Expand Down Expand Up @@ -230,6 +232,8 @@ def test_setattr_cs(checkedsession):
"Input should be an instance of Axis. Got input value of type 'int'."):
cs.a = 0
# -> CheckedArray
# with must_raise(TypeError, msg="Error while assigning value to variable 'h':\n"
# "Input should be an instance of Array. Got input value of type 'ndarray'."):
with must_raise(TypeError, msg="Expected object of type 'Array' or a scalar for the variable 'h' but got "
"object of type 'ndarray'"):
cs.h = h.data
Expand Down Expand Up @@ -728,10 +732,15 @@ def save(self, path=None, **kwargs):
def new_method(self):
return True

@property
def new_property(self):
return "property value"

array = ndtest(a)

cs = CheckedSessionWithMethods(arr=array)
assert cs.new_method()
assert cs.new_property == "property value"


if __name__ == "__main__":
Expand Down
24 changes: 24 additions & 0 deletions larray/util/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -1081,3 +1081,27 @@ def concatenate_ndarrays(arrays) -> np.ndarray:

def first(iterable, default=None):
return next(iter(iterable), default)


try:
# Python 3.14+
import annotationlib

def get_annotations(namespace):
# should not happen in Python3.14+ unless
# "from __future__ import annotations" is used
if "__annotations__" in namespace:
return namespace["__annotations__"]
elif annotate := annotationlib.get_annotate_from_class_namespace(namespace):
return annotationlib.call_annotate_function(
annotate, format=annotationlib.Format.FORWARDREF
)
else:
return {}
except ImportError:
# Python <3.14
def get_annotations(namespace):
# any type hints defined in the class body will land in a
# __annotations__ key in its namespace (this is not pydantic-specific)
# but __annotations__ is only defined if there are type hints
return namespace.get('__annotations__', {})
2 changes: 1 addition & 1 deletion make_release.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def update_metapackage(local_repository, release_name, public_release=True, **ex
print(f'Updating larrayenv metapackage to version {version}')
dependencies = [
f'larray =={version}', f'larray-editor =={version}', f'larray_eurostat =={version}',
'qtconsole', 'matplotlib', 'pyqt', 'qtpy', 'pytables', 'pydantic >=2.12',
'qtconsole', 'matplotlib', 'pyqt', 'qtpy', 'pytables', 'pydantic',
'xlsxwriter', 'xlrd', 'openpyxl', 'xlwings',
]
check_call([
Expand Down
Loading