From 5898ddc450d929c9c51088e09a8301d402bd1e7f Mon Sep 17 00:00:00 2001 From: Paul Sharp <44529197+DrPaulSharp@users.noreply.github.com> Date: Thu, 30 May 2024 11:04:34 +0100 Subject: [PATCH] Bumps pydantic to version 2.7.2 --- pyproject.toml | 2 +- requirements.txt | 2 +- setup.py | 46 +++++++++++++++++++++--------------------- tests/test_controls.py | 18 ++++++----------- 4 files changed, 31 insertions(+), 37 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index f06d4e21..29d309a0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -9,7 +9,7 @@ build-backend = 'setuptools.build_meta' dependencies = [ 'numpy >= 1.20', 'prettytable>=3.9.0', - 'pydantic>=2.4.2,<=2.6.4', + 'pydantic>=2.7.2', 'StrEnum>=0.4.15; python_version<"3.11"', ] diff --git a/requirements.txt b/requirements.txt index d86d2294..f1f3dca6 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,7 @@ numpy >= 1.20 prettytable >= 3.9.0 pybind11 >= 2.4 -pydantic >= 2.4.2, <= 2.6.4 +pydantic >= 2.7.2 pytest >= 7.4.0 pytest-cov >= 4.1.0 matplotlib >= 3.8.3 diff --git a/setup.py b/setup.py index da896906..cca3c73b 100644 --- a/setup.py +++ b/setup.py @@ -146,28 +146,28 @@ def build_libraries(self, libraries): setup( - name = 'RAT', - version = __version__, - author = '', - author_email = '', - url = 'https://github.com/RascalSoftware/python-RAT', - description = 'Python extension for the Reflectivity Analysis Toolbox (RAT)', - packages = find_packages(), - include_package_data = True, - package_data = {'': [get_shared_object_name(libevent[0])]}, - cmdclass = {'build_clib': BuildClib, 'build_ext': BuildExt}, - libraries = [libevent], - ext_modules = ext_modules, - python_requires = '>=3.9', - install_requires = ['numpy >= 1.20', 'prettytable >= 3.9.0', 'pydantic >= 2.4.2, <= 2.6.4', 'matplotlib >= 3.8.3'], - extras_require = {':python_version < "3.11"': ['StrEnum >= 0.4.15'], - 'Dev': ['pytest>=7.4.0', 'pytest-cov>=4.1.0'], - 'Matlab_latest': ['matlabengine'], - 'Matlab_2023b': ['matlabengine == 23.2.1'], - 'Matlab_2023a': ['matlabengine == 9.14.3'], - 'Matlab-2022b': ['matlabengine == 9.13.9'], - 'Matlab_2022a': ['matlabengine == 9.12.19'], - 'Matlab_2021b': ['matlabengine == 9.11.21'], - 'Matlab_2021a': ['matlabengine == 9.10.3']}, + name='RAT', + version=__version__, + author='', + author_email='', + url='https://github.com/RascalSoftware/python-RAT', + description='Python extension for the Reflectivity Analysis Toolbox (RAT)', + packages=find_packages(), + include_package_data=True, + package_data={'': [get_shared_object_name(libevent[0])]}, + cmdclass={'build_clib': BuildClib, 'build_ext': BuildExt}, + libraries=[libevent], + ext_modules=ext_modules, + python_requires='>=3.9', + install_requires=['numpy >= 1.20', 'prettytable >= 3.9.0', 'pydantic >= 2.7.2', 'matplotlib >= 3.8.3'], + extras_require={':python_version < "3.11"': ['StrEnum >= 0.4.15'], + 'Dev': ['pytest>=7.4.0', 'pytest-cov>=4.1.0'], + 'Matlab_latest': ['matlabengine'], + 'Matlab_2023b': ['matlabengine == 23.2.1'], + 'Matlab_2023a': ['matlabengine == 9.14.3'], + 'Matlab-2022b': ['matlabengine == 9.13.9'], + 'Matlab_2022a': ['matlabengine == 9.12.19'], + 'Matlab_2021b': ['matlabengine == 9.11.21'], + 'Matlab_2021a': ['matlabengine == 9.10.3']}, zip_safe=False, ) diff --git a/tests/test_controls.py b/tests/test_controls.py index bdcf9378..27d48497 100644 --- a/tests/test_controls.py +++ b/tests/test_controls.py @@ -37,15 +37,12 @@ def test_calculate_property_setters(self, control_property: str, value: Any) -> setattr(self.calculate, control_property, value) assert getattr(self.calculate, control_property) == value - @pytest.mark.parametrize("var1, var2", [('test', True), ('ALL', 1), ("Contrast", 3.0)]) - def test_calculate_parallel_validation(self, var1: str, var2: Any) -> None: + @pytest.mark.parametrize("value", ['test', 'ALL', 'Contrast', True, 1, 3.0]) + def test_calculate_parallel_validation(self, value: Any) -> None: """Tests the parallel setter validation in Calculate class.""" with pytest.raises(pydantic.ValidationError) as exp: - setattr(self.calculate, 'parallel', var1) + setattr(self.calculate, 'parallel', value) assert exp.value.errors()[0]['msg'] == "Input should be 'single', 'points' or 'contrasts'" - with pytest.raises(pydantic.ValidationError) as exp: - setattr(self.calculate, 'parallel', var2) - assert exp.value.errors()[0]['msg'] == "Input should be a valid string" @pytest.mark.parametrize("value", [5.0, 12]) def test_calculate_calcSldDuringFit_validation(self, value: Union[int, float]) -> None: @@ -54,15 +51,12 @@ def test_calculate_calcSldDuringFit_validation(self, value: Union[int, float]) - setattr(self.calculate, 'calcSldDuringFit', value) assert exp.value.errors()[0]['msg'] == "Input should be a valid boolean, unable to interpret input" - @pytest.mark.parametrize("var1, var2", [('test', True), ('iterate', 1), ("FINAL", 3.0)]) - def test_calculate_display_validation(self, var1: str, var2: Any) -> None: + @pytest.mark.parametrize("value", ['test', 'iterate', "FINAL", True, 1, 3.0]) + def test_calculate_display_validation(self, value: Any) -> None: """Tests the display setter validation in Calculate class.""" with pytest.raises(pydantic.ValidationError) as exp: - setattr(self.calculate, 'display', var1) + setattr(self.calculate, 'display', value) assert exp.value.errors()[0]['msg'] == "Input should be 'off', 'iter', 'notify' or 'final'" - with pytest.raises(pydantic.ValidationError) as exp: - setattr(self.calculate, 'display', var2) - assert exp.value.errors()[0]['msg'] == "Input should be a valid string" @pytest.mark.parametrize("value, msg", [ ([5.0], "List should have at least 2 items after validation, not 1"),