From c0c1fc389bf74e02ffdcffd45271a9a950d48c13 Mon Sep 17 00:00:00 2001 From: caniko Date: Tue, 2 Apr 2024 09:40:21 +0200 Subject: [PATCH] test(refactor): Adapt to new schema test(dependency): Remove hypothesis as a dependency from the testing suite --- Justfile | 6 +- poetry.lock | 297 +++++++++++----------------- pydantic_numpy/helper/annotation.py | 24 +-- pyproject.toml | 10 +- tests/helper/cache.py | 31 +-- tests/helper/groups.py | 210 -------------------- tests/helper/testing_groups.py | 199 +++++++++++++++++++ tests/test_np_model.py | 15 +- tests/test_pydantic.py | 2 +- tests/test_typing.py | 109 +++++----- 10 files changed, 398 insertions(+), 505 deletions(-) delete mode 100644 tests/helper/groups.py create mode 100644 tests/helper/testing_groups.py diff --git a/Justfile b/Justfile index dfa29f4..d22fea0 100644 --- a/Justfile +++ b/Justfile @@ -7,7 +7,7 @@ test: format: poetry run black . poetry run isort . - poetry run ruff check . --fix + poetry run ruff check --fix --exit-zero . @echo "Formatting complete 🎉" mypy: @@ -26,4 +26,6 @@ pyright_test: poetry run pyright tests/ typegen: - poetry run python typegen/generate_typing.py \ No newline at end of file + poetry run python typegen/generate_typing.py + +check: format pyright test \ No newline at end of file diff --git a/poetry.lock b/poetry.lock index a064cfd..31943ae 100644 --- a/poetry.lock +++ b/poetry.lock @@ -11,25 +11,6 @@ files = [ {file = "annotated_types-0.6.0.tar.gz", hash = "sha256:563339e807e53ffd9c267e99fc6d9ea23eb8443c08f112651963e24e22f84a5d"}, ] -[[package]] -name = "attrs" -version = "23.2.0" -description = "Classes Without Boilerplate" -optional = false -python-versions = ">=3.7" -files = [ - {file = "attrs-23.2.0-py3-none-any.whl", hash = "sha256:99b87a485a5820b23b879f04c2305b44b951b502fd64be915879d77a7e8fc6f1"}, - {file = "attrs-23.2.0.tar.gz", hash = "sha256:935dc3b529c262f6cf76e50877d35a4bd3c1de194fd41f47a2b7ae8f19971f30"}, -] - -[package.extras] -cov = ["attrs[tests]", "coverage[toml] (>=5.3)"] -dev = ["attrs[tests]", "pre-commit"] -docs = ["furo", "myst-parser", "sphinx", "sphinx-notfound-page", "sphinxcontrib-towncrier", "towncrier", "zope-interface"] -tests = ["attrs[tests-no-zope]", "zope-interface"] -tests-mypy = ["mypy (>=1.6)", "pytest-mypy-plugins"] -tests-no-zope = ["attrs[tests-mypy]", "cloudpickle", "hypothesis", "pympler", "pytest (>=4.3.0)", "pytest-xdist[psutil]"] - [[package]] name = "black" version = "23.12.1" @@ -135,39 +116,6 @@ files = [ [package.extras] test = ["pytest (>=6)"] -[[package]] -name = "hypothesis" -version = "6.100.0" -description = "A library for property-based testing" -optional = false -python-versions = ">=3.8" -files = [ - {file = "hypothesis-6.100.0-py3-none-any.whl", hash = "sha256:ceaeb7c051085dbec37f2fc4dca524b6304472ff1887fed53b3d84705507c10e"}, - {file = "hypothesis-6.100.0.tar.gz", hash = "sha256:1841f6b5083844cd4b66965e44a17c0dc8fe8e9c6370c1f7b8d50647fcb2efd3"}, -] - -[package.dependencies] -attrs = ">=22.2.0" -exceptiongroup = {version = ">=1.0.0", markers = "python_version < \"3.11\""} -sortedcontainers = ">=2.1.0,<3.0.0" - -[package.extras] -all = ["backports.zoneinfo (>=0.2.1)", "black (>=19.10b0)", "click (>=7.0)", "crosshair-tool (>=0.0.54)", "django (>=3.2)", "dpcontracts (>=0.4)", "hypothesis-crosshair (>=0.0.2)", "lark (>=0.10.1)", "libcst (>=0.3.16)", "numpy (>=1.17.3)", "pandas (>=1.1)", "pytest (>=4.6)", "python-dateutil (>=1.4)", "pytz (>=2014.1)", "redis (>=3.0.0)", "rich (>=9.0.0)", "tzdata (>=2024.1)"] -cli = ["black (>=19.10b0)", "click (>=7.0)", "rich (>=9.0.0)"] -codemods = ["libcst (>=0.3.16)"] -crosshair = ["crosshair-tool (>=0.0.54)", "hypothesis-crosshair (>=0.0.2)"] -dateutil = ["python-dateutil (>=1.4)"] -django = ["django (>=3.2)"] -dpcontracts = ["dpcontracts (>=0.4)"] -ghostwriter = ["black (>=19.10b0)"] -lark = ["lark (>=0.10.1)"] -numpy = ["numpy (>=1.17.3)"] -pandas = ["pandas (>=1.1)"] -pytest = ["pytest (>=4.6)"] -pytz = ["pytz (>=2014.1)"] -redis = ["redis (>=3.0.0)"] -zoneinfo = ["backports.zoneinfo (>=0.2.1)", "tzdata (>=2024.1)"] - [[package]] name = "iniconfig" version = "2.0.0" @@ -488,18 +436,18 @@ testing = ["pytest", "pytest-benchmark"] [[package]] name = "pydantic" -version = "2.6.4" +version = "2.7.0" description = "Data validation using Python type hints" optional = false python-versions = ">=3.8" files = [ - {file = "pydantic-2.6.4-py3-none-any.whl", hash = "sha256:cc46fce86607580867bdc3361ad462bab9c222ef042d3da86f2fb333e1d916c5"}, - {file = "pydantic-2.6.4.tar.gz", hash = "sha256:b1704e0847db01817624a6b86766967f552dd9dbf3afba4004409f908dcc84e6"}, + {file = "pydantic-2.7.0-py3-none-any.whl", hash = "sha256:9dee74a271705f14f9a1567671d144a851c675b072736f0a7b2608fd9e495352"}, + {file = "pydantic-2.7.0.tar.gz", hash = "sha256:b5ecdd42262ca2462e2624793551e80911a1e989f462910bb81aef974b4bb383"}, ] [package.dependencies] annotated-types = ">=0.4.0" -pydantic-core = "2.16.3" +pydantic-core = "2.18.1" typing-extensions = ">=4.6.1" [package.extras] @@ -507,90 +455,90 @@ email = ["email-validator (>=2.0.0)"] [[package]] name = "pydantic-core" -version = "2.16.3" -description = "" +version = "2.18.1" +description = "Core functionality for Pydantic validation and serialization" optional = false python-versions = ">=3.8" files = [ - {file = "pydantic_core-2.16.3-cp310-cp310-macosx_10_12_x86_64.whl", hash = "sha256:75b81e678d1c1ede0785c7f46690621e4c6e63ccd9192af1f0bd9d504bbb6bf4"}, - {file = "pydantic_core-2.16.3-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:9c865a7ee6f93783bd5d781af5a4c43dadc37053a5b42f7d18dc019f8c9d2bd1"}, - {file = "pydantic_core-2.16.3-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:162e498303d2b1c036b957a1278fa0899d02b2842f1ff901b6395104c5554a45"}, - {file = "pydantic_core-2.16.3-cp310-cp310-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:2f583bd01bbfbff4eaee0868e6fc607efdfcc2b03c1c766b06a707abbc856187"}, - {file = "pydantic_core-2.16.3-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:b926dd38db1519ed3043a4de50214e0d600d404099c3392f098a7f9d75029ff8"}, - {file = "pydantic_core-2.16.3-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:716b542728d4c742353448765aa7cdaa519a7b82f9564130e2b3f6766018c9ec"}, - {file = "pydantic_core-2.16.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:fc4ad7f7ee1a13d9cb49d8198cd7d7e3aa93e425f371a68235f784e99741561f"}, - {file = "pydantic_core-2.16.3-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:bd87f48924f360e5d1c5f770d6155ce0e7d83f7b4e10c2f9ec001c73cf475c99"}, - {file = "pydantic_core-2.16.3-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:0df446663464884297c793874573549229f9eca73b59360878f382a0fc085979"}, - {file = "pydantic_core-2.16.3-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:4df8a199d9f6afc5ae9a65f8f95ee52cae389a8c6b20163762bde0426275b7db"}, - {file = "pydantic_core-2.16.3-cp310-none-win32.whl", hash = "sha256:456855f57b413f077dff513a5a28ed838dbbb15082ba00f80750377eed23d132"}, - {file = "pydantic_core-2.16.3-cp310-none-win_amd64.whl", hash = "sha256:732da3243e1b8d3eab8c6ae23ae6a58548849d2e4a4e03a1924c8ddf71a387cb"}, - {file = "pydantic_core-2.16.3-cp311-cp311-macosx_10_12_x86_64.whl", hash = "sha256:519ae0312616026bf4cedc0fe459e982734f3ca82ee8c7246c19b650b60a5ee4"}, - {file = "pydantic_core-2.16.3-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:b3992a322a5617ded0a9f23fd06dbc1e4bd7cf39bc4ccf344b10f80af58beacd"}, - {file = "pydantic_core-2.16.3-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:8d62da299c6ecb04df729e4b5c52dc0d53f4f8430b4492b93aa8de1f541c4aac"}, - {file = "pydantic_core-2.16.3-cp311-cp311-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:2acca2be4bb2f2147ada8cac612f8a98fc09f41c89f87add7256ad27332c2fda"}, - {file = "pydantic_core-2.16.3-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:1b662180108c55dfbf1280d865b2d116633d436cfc0bba82323554873967b340"}, - {file = "pydantic_core-2.16.3-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:e7c6ed0dc9d8e65f24f5824291550139fe6f37fac03788d4580da0d33bc00c97"}, - {file = "pydantic_core-2.16.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a6b1bb0827f56654b4437955555dc3aeeebeddc47c2d7ed575477f082622c49e"}, - {file = "pydantic_core-2.16.3-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:e56f8186d6210ac7ece503193ec84104da7ceb98f68ce18c07282fcc2452e76f"}, - {file = "pydantic_core-2.16.3-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:936e5db01dd49476fa8f4383c259b8b1303d5dd5fb34c97de194560698cc2c5e"}, - {file = "pydantic_core-2.16.3-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:33809aebac276089b78db106ee692bdc9044710e26f24a9a2eaa35a0f9fa70ba"}, - {file = "pydantic_core-2.16.3-cp311-none-win32.whl", hash = "sha256:ded1c35f15c9dea16ead9bffcde9bb5c7c031bff076355dc58dcb1cb436c4721"}, - {file = "pydantic_core-2.16.3-cp311-none-win_amd64.whl", hash = "sha256:d89ca19cdd0dd5f31606a9329e309d4fcbb3df860960acec32630297d61820df"}, - {file = "pydantic_core-2.16.3-cp311-none-win_arm64.whl", hash = "sha256:6162f8d2dc27ba21027f261e4fa26f8bcb3cf9784b7f9499466a311ac284b5b9"}, - {file = "pydantic_core-2.16.3-cp312-cp312-macosx_10_12_x86_64.whl", hash = "sha256:0f56ae86b60ea987ae8bcd6654a887238fd53d1384f9b222ac457070b7ac4cff"}, - {file = "pydantic_core-2.16.3-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:c9bd22a2a639e26171068f8ebb5400ce2c1bc7d17959f60a3b753ae13c632975"}, - {file = "pydantic_core-2.16.3-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:4204e773b4b408062960e65468d5346bdfe139247ee5f1ca2a378983e11388a2"}, - {file = "pydantic_core-2.16.3-cp312-cp312-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:f651dd19363c632f4abe3480a7c87a9773be27cfe1341aef06e8759599454120"}, - {file = "pydantic_core-2.16.3-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:aaf09e615a0bf98d406657e0008e4a8701b11481840be7d31755dc9f97c44053"}, - {file = "pydantic_core-2.16.3-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:8e47755d8152c1ab5b55928ab422a76e2e7b22b5ed8e90a7d584268dd49e9c6b"}, - {file = "pydantic_core-2.16.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:500960cb3a0543a724a81ba859da816e8cf01b0e6aaeedf2c3775d12ee49cade"}, - {file = "pydantic_core-2.16.3-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:cf6204fe865da605285c34cf1172879d0314ff267b1c35ff59de7154f35fdc2e"}, - {file = "pydantic_core-2.16.3-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:d33dd21f572545649f90c38c227cc8631268ba25c460b5569abebdd0ec5974ca"}, - {file = "pydantic_core-2.16.3-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:49d5d58abd4b83fb8ce763be7794d09b2f50f10aa65c0f0c1696c677edeb7cbf"}, - {file = "pydantic_core-2.16.3-cp312-none-win32.whl", hash = "sha256:f53aace168a2a10582e570b7736cc5bef12cae9cf21775e3eafac597e8551fbe"}, - {file = "pydantic_core-2.16.3-cp312-none-win_amd64.whl", hash = "sha256:0d32576b1de5a30d9a97f300cc6a3f4694c428d956adbc7e6e2f9cad279e45ed"}, - {file = "pydantic_core-2.16.3-cp312-none-win_arm64.whl", hash = "sha256:ec08be75bb268473677edb83ba71e7e74b43c008e4a7b1907c6d57e940bf34b6"}, - {file = "pydantic_core-2.16.3-cp38-cp38-macosx_10_12_x86_64.whl", hash = "sha256:b1f6f5938d63c6139860f044e2538baeee6f0b251a1816e7adb6cbce106a1f01"}, - {file = "pydantic_core-2.16.3-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:2a1ef6a36fdbf71538142ed604ad19b82f67b05749512e47f247a6ddd06afdc7"}, - {file = "pydantic_core-2.16.3-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:704d35ecc7e9c31d48926150afada60401c55efa3b46cd1ded5a01bdffaf1d48"}, - {file = "pydantic_core-2.16.3-cp38-cp38-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:d937653a696465677ed583124b94a4b2d79f5e30b2c46115a68e482c6a591c8a"}, - {file = "pydantic_core-2.16.3-cp38-cp38-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:c9803edf8e29bd825f43481f19c37f50d2b01899448273b3a7758441b512acf8"}, - {file = "pydantic_core-2.16.3-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:72282ad4892a9fb2da25defeac8c2e84352c108705c972db82ab121d15f14e6d"}, - {file = "pydantic_core-2.16.3-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:7f752826b5b8361193df55afcdf8ca6a57d0232653494ba473630a83ba50d8c9"}, - {file = "pydantic_core-2.16.3-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:4384a8f68ddb31a0b0c3deae88765f5868a1b9148939c3f4121233314ad5532c"}, - {file = "pydantic_core-2.16.3-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:a4b2bf78342c40b3dc830880106f54328928ff03e357935ad26c7128bbd66ce8"}, - {file = "pydantic_core-2.16.3-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:13dcc4802961b5f843a9385fc821a0b0135e8c07fc3d9949fd49627c1a5e6ae5"}, - {file = "pydantic_core-2.16.3-cp38-none-win32.whl", hash = "sha256:e3e70c94a0c3841e6aa831edab1619ad5c511199be94d0c11ba75fe06efe107a"}, - {file = "pydantic_core-2.16.3-cp38-none-win_amd64.whl", hash = "sha256:ecdf6bf5f578615f2e985a5e1f6572e23aa632c4bd1dc67f8f406d445ac115ed"}, - {file = "pydantic_core-2.16.3-cp39-cp39-macosx_10_12_x86_64.whl", hash = "sha256:bda1ee3e08252b8d41fa5537413ffdddd58fa73107171a126d3b9ff001b9b820"}, - {file = "pydantic_core-2.16.3-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:21b888c973e4f26b7a96491c0965a8a312e13be108022ee510248fe379a5fa23"}, - {file = "pydantic_core-2.16.3-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:be0ec334369316fa73448cc8c982c01e5d2a81c95969d58b8f6e272884df0074"}, - {file = "pydantic_core-2.16.3-cp39-cp39-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:b5b6079cc452a7c53dd378c6f881ac528246b3ac9aae0f8eef98498a75657805"}, - {file = "pydantic_core-2.16.3-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:7ee8d5f878dccb6d499ba4d30d757111847b6849ae07acdd1205fffa1fc1253c"}, - {file = "pydantic_core-2.16.3-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:7233d65d9d651242a68801159763d09e9ec96e8a158dbf118dc090cd77a104c9"}, - {file = "pydantic_core-2.16.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:c6119dc90483a5cb50a1306adb8d52c66e447da88ea44f323e0ae1a5fcb14256"}, - {file = "pydantic_core-2.16.3-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:578114bc803a4c1ff9946d977c221e4376620a46cf78da267d946397dc9514a8"}, - {file = "pydantic_core-2.16.3-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:d8f99b147ff3fcf6b3cc60cb0c39ea443884d5559a30b1481e92495f2310ff2b"}, - {file = "pydantic_core-2.16.3-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:4ac6b4ce1e7283d715c4b729d8f9dab9627586dafce81d9eaa009dd7f25dd972"}, - {file = "pydantic_core-2.16.3-cp39-none-win32.whl", hash = "sha256:e7774b570e61cb998490c5235740d475413a1f6de823169b4cf94e2fe9e9f6b2"}, - {file = "pydantic_core-2.16.3-cp39-none-win_amd64.whl", hash = "sha256:9091632a25b8b87b9a605ec0e61f241c456e9248bfdcf7abdf344fdb169c81cf"}, - {file = "pydantic_core-2.16.3-pp310-pypy310_pp73-macosx_10_12_x86_64.whl", hash = "sha256:36fa178aacbc277bc6b62a2c3da95226520da4f4e9e206fdf076484363895d2c"}, - {file = "pydantic_core-2.16.3-pp310-pypy310_pp73-macosx_11_0_arm64.whl", hash = "sha256:dcca5d2bf65c6fb591fff92da03f94cd4f315972f97c21975398bd4bd046854a"}, - {file = "pydantic_core-2.16.3-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:2a72fb9963cba4cd5793854fd12f4cfee731e86df140f59ff52a49b3552db241"}, - {file = "pydantic_core-2.16.3-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:b60cc1a081f80a2105a59385b92d82278b15d80ebb3adb200542ae165cd7d183"}, - {file = "pydantic_core-2.16.3-pp310-pypy310_pp73-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:cbcc558401de90a746d02ef330c528f2e668c83350f045833543cd57ecead1ad"}, - {file = "pydantic_core-2.16.3-pp310-pypy310_pp73-musllinux_1_1_aarch64.whl", hash = "sha256:fee427241c2d9fb7192b658190f9f5fd6dfe41e02f3c1489d2ec1e6a5ab1e04a"}, - {file = "pydantic_core-2.16.3-pp310-pypy310_pp73-musllinux_1_1_x86_64.whl", hash = "sha256:f4cb85f693044e0f71f394ff76c98ddc1bc0953e48c061725e540396d5c8a2e1"}, - {file = "pydantic_core-2.16.3-pp310-pypy310_pp73-win_amd64.whl", hash = "sha256:b29eeb887aa931c2fcef5aa515d9d176d25006794610c264ddc114c053bf96fe"}, - {file = "pydantic_core-2.16.3-pp39-pypy39_pp73-macosx_10_12_x86_64.whl", hash = "sha256:a425479ee40ff021f8216c9d07a6a3b54b31c8267c6e17aa88b70d7ebd0e5e5b"}, - {file = "pydantic_core-2.16.3-pp39-pypy39_pp73-macosx_11_0_arm64.whl", hash = "sha256:5c5cbc703168d1b7a838668998308018a2718c2130595e8e190220238addc96f"}, - {file = "pydantic_core-2.16.3-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:99b6add4c0b39a513d323d3b93bc173dac663c27b99860dd5bf491b240d26137"}, - {file = "pydantic_core-2.16.3-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:75f76ee558751746d6a38f89d60b6228fa174e5172d143886af0f85aa306fd89"}, - {file = "pydantic_core-2.16.3-pp39-pypy39_pp73-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:00ee1c97b5364b84cb0bd82e9bbf645d5e2871fb8c58059d158412fee2d33d8a"}, - {file = "pydantic_core-2.16.3-pp39-pypy39_pp73-musllinux_1_1_aarch64.whl", hash = "sha256:287073c66748f624be4cef893ef9174e3eb88fe0b8a78dc22e88eca4bc357ca6"}, - {file = "pydantic_core-2.16.3-pp39-pypy39_pp73-musllinux_1_1_x86_64.whl", hash = "sha256:ed25e1835c00a332cb10c683cd39da96a719ab1dfc08427d476bce41b92531fc"}, - {file = "pydantic_core-2.16.3-pp39-pypy39_pp73-win_amd64.whl", hash = "sha256:86b3d0033580bd6bbe07590152007275bd7af95f98eaa5bd36f3da219dcd93da"}, - {file = "pydantic_core-2.16.3.tar.gz", hash = "sha256:1cac689f80a3abab2d3c0048b29eea5751114054f032a941a32de4c852c59cad"}, + {file = "pydantic_core-2.18.1-cp310-cp310-macosx_10_12_x86_64.whl", hash = "sha256:ee9cf33e7fe14243f5ca6977658eb7d1042caaa66847daacbd2117adb258b226"}, + {file = "pydantic_core-2.18.1-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:6b7bbb97d82659ac8b37450c60ff2e9f97e4eb0f8a8a3645a5568b9334b08b50"}, + {file = "pydantic_core-2.18.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:df4249b579e75094f7e9bb4bd28231acf55e308bf686b952f43100a5a0be394c"}, + {file = "pydantic_core-2.18.1-cp310-cp310-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:d0491006a6ad20507aec2be72e7831a42efc93193d2402018007ff827dc62926"}, + {file = "pydantic_core-2.18.1-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:2ae80f72bb7a3e397ab37b53a2b49c62cc5496412e71bc4f1277620a7ce3f52b"}, + {file = "pydantic_core-2.18.1-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:58aca931bef83217fca7a390e0486ae327c4af9c3e941adb75f8772f8eeb03a1"}, + {file = "pydantic_core-2.18.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:1be91ad664fc9245404a789d60cba1e91c26b1454ba136d2a1bf0c2ac0c0505a"}, + {file = "pydantic_core-2.18.1-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:667880321e916a8920ef49f5d50e7983792cf59f3b6079f3c9dac2b88a311d17"}, + {file = "pydantic_core-2.18.1-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:f7054fdc556f5421f01e39cbb767d5ec5c1139ea98c3e5b350e02e62201740c7"}, + {file = "pydantic_core-2.18.1-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:030e4f9516f9947f38179249778709a460a3adb516bf39b5eb9066fcfe43d0e6"}, + {file = "pydantic_core-2.18.1-cp310-none-win32.whl", hash = "sha256:2e91711e36e229978d92642bfc3546333a9127ecebb3f2761372e096395fc649"}, + {file = "pydantic_core-2.18.1-cp310-none-win_amd64.whl", hash = "sha256:9a29726f91c6cb390b3c2338f0df5cd3e216ad7a938762d11c994bb37552edb0"}, + {file = "pydantic_core-2.18.1-cp311-cp311-macosx_10_12_x86_64.whl", hash = "sha256:9ece8a49696669d483d206b4474c367852c44815fca23ac4e48b72b339807f80"}, + {file = "pydantic_core-2.18.1-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:7a5d83efc109ceddb99abd2c1316298ced2adb4570410defe766851a804fcd5b"}, + {file = "pydantic_core-2.18.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:5f7973c381283783cd1043a8c8f61ea5ce7a3a58b0369f0ee0ee975eaf2f2a1b"}, + {file = "pydantic_core-2.18.1-cp311-cp311-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:54c7375c62190a7845091f521add19b0f026bcf6ae674bdb89f296972272e86d"}, + {file = "pydantic_core-2.18.1-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:dd63cec4e26e790b70544ae5cc48d11b515b09e05fdd5eff12e3195f54b8a586"}, + {file = "pydantic_core-2.18.1-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:561cf62c8a3498406495cfc49eee086ed2bb186d08bcc65812b75fda42c38294"}, + {file = "pydantic_core-2.18.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:68717c38a68e37af87c4da20e08f3e27d7e4212e99e96c3d875fbf3f4812abfc"}, + {file = "pydantic_core-2.18.1-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:2d5728e93d28a3c63ee513d9ffbac9c5989de8c76e049dbcb5bfe4b923a9739d"}, + {file = "pydantic_core-2.18.1-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:f0f17814c505f07806e22b28856c59ac80cee7dd0fbb152aed273e116378f519"}, + {file = "pydantic_core-2.18.1-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:d816f44a51ba5175394bc6c7879ca0bd2be560b2c9e9f3411ef3a4cbe644c2e9"}, + {file = "pydantic_core-2.18.1-cp311-none-win32.whl", hash = "sha256:09f03dfc0ef8c22622eaa8608caa4a1e189cfb83ce847045eca34f690895eccb"}, + {file = "pydantic_core-2.18.1-cp311-none-win_amd64.whl", hash = "sha256:27f1009dc292f3b7ca77feb3571c537276b9aad5dd4efb471ac88a8bd09024e9"}, + {file = "pydantic_core-2.18.1-cp311-none-win_arm64.whl", hash = "sha256:48dd883db92e92519201f2b01cafa881e5f7125666141a49ffba8b9facc072b0"}, + {file = "pydantic_core-2.18.1-cp312-cp312-macosx_10_12_x86_64.whl", hash = "sha256:b6b0e4912030c6f28bcb72b9ebe4989d6dc2eebcd2a9cdc35fefc38052dd4fe8"}, + {file = "pydantic_core-2.18.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:f3202a429fe825b699c57892d4371c74cc3456d8d71b7f35d6028c96dfecad31"}, + {file = "pydantic_core-2.18.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a3982b0a32d0a88b3907e4b0dc36809fda477f0757c59a505d4e9b455f384b8b"}, + {file = "pydantic_core-2.18.1-cp312-cp312-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:25595ac311f20e5324d1941909b0d12933f1fd2171075fcff763e90f43e92a0d"}, + {file = "pydantic_core-2.18.1-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:14fe73881cf8e4cbdaded8ca0aa671635b597e42447fec7060d0868b52d074e6"}, + {file = "pydantic_core-2.18.1-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:ca976884ce34070799e4dfc6fbd68cb1d181db1eefe4a3a94798ddfb34b8867f"}, + {file = "pydantic_core-2.18.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:684d840d2c9ec5de9cb397fcb3f36d5ebb6fa0d94734f9886032dd796c1ead06"}, + {file = "pydantic_core-2.18.1-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:54764c083bbe0264f0f746cefcded6cb08fbbaaf1ad1d78fb8a4c30cff999a90"}, + {file = "pydantic_core-2.18.1-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:201713f2f462e5c015b343e86e68bd8a530a4f76609b33d8f0ec65d2b921712a"}, + {file = "pydantic_core-2.18.1-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:fd1a9edb9dd9d79fbeac1ea1f9a8dd527a6113b18d2e9bcc0d541d308dae639b"}, + {file = "pydantic_core-2.18.1-cp312-none-win32.whl", hash = "sha256:d5e6b7155b8197b329dc787356cfd2684c9d6a6b1a197f6bbf45f5555a98d411"}, + {file = "pydantic_core-2.18.1-cp312-none-win_amd64.whl", hash = "sha256:9376d83d686ec62e8b19c0ac3bf8d28d8a5981d0df290196fb6ef24d8a26f0d6"}, + {file = "pydantic_core-2.18.1-cp312-none-win_arm64.whl", hash = "sha256:c562b49c96906b4029b5685075fe1ebd3b5cc2601dfa0b9e16c2c09d6cbce048"}, + {file = "pydantic_core-2.18.1-cp38-cp38-macosx_10_12_x86_64.whl", hash = "sha256:3e352f0191d99fe617371096845070dee295444979efb8f27ad941227de6ad09"}, + {file = "pydantic_core-2.18.1-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:c0295d52b012cbe0d3059b1dba99159c3be55e632aae1999ab74ae2bd86a33d7"}, + {file = "pydantic_core-2.18.1-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:56823a92075780582d1ffd4489a2e61d56fd3ebb4b40b713d63f96dd92d28144"}, + {file = "pydantic_core-2.18.1-cp38-cp38-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:dd3f79e17b56741b5177bcc36307750d50ea0698df6aa82f69c7db32d968c1c2"}, + {file = "pydantic_core-2.18.1-cp38-cp38-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:38a5024de321d672a132b1834a66eeb7931959c59964b777e8f32dbe9523f6b1"}, + {file = "pydantic_core-2.18.1-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:d2ce426ee691319d4767748c8e0895cfc56593d725594e415f274059bcf3cb76"}, + {file = "pydantic_core-2.18.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:2adaeea59849ec0939af5c5d476935f2bab4b7f0335b0110f0f069a41024278e"}, + {file = "pydantic_core-2.18.1-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:9b6431559676a1079eac0f52d6d0721fb8e3c5ba43c37bc537c8c83724031feb"}, + {file = "pydantic_core-2.18.1-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:85233abb44bc18d16e72dc05bf13848a36f363f83757541f1a97db2f8d58cfd9"}, + {file = "pydantic_core-2.18.1-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:641a018af4fe48be57a2b3d7a1f0f5dbca07c1d00951d3d7463f0ac9dac66622"}, + {file = "pydantic_core-2.18.1-cp38-none-win32.whl", hash = "sha256:63d7523cd95d2fde0d28dc42968ac731b5bb1e516cc56b93a50ab293f4daeaad"}, + {file = "pydantic_core-2.18.1-cp38-none-win_amd64.whl", hash = "sha256:907a4d7720abfcb1c81619863efd47c8a85d26a257a2dbebdb87c3b847df0278"}, + {file = "pydantic_core-2.18.1-cp39-cp39-macosx_10_12_x86_64.whl", hash = "sha256:aad17e462f42ddbef5984d70c40bfc4146c322a2da79715932cd8976317054de"}, + {file = "pydantic_core-2.18.1-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:94b9769ba435b598b547c762184bcfc4783d0d4c7771b04a3b45775c3589ca44"}, + {file = "pydantic_core-2.18.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:80e0e57cc704a52fb1b48f16d5b2c8818da087dbee6f98d9bf19546930dc64b5"}, + {file = "pydantic_core-2.18.1-cp39-cp39-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:76b86e24039c35280ceee6dce7e62945eb93a5175d43689ba98360ab31eebc4a"}, + {file = "pydantic_core-2.18.1-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:12a05db5013ec0ca4a32cc6433f53faa2a014ec364031408540ba858c2172bb0"}, + {file = "pydantic_core-2.18.1-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:250ae39445cb5475e483a36b1061af1bc233de3e9ad0f4f76a71b66231b07f88"}, + {file = "pydantic_core-2.18.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a32204489259786a923e02990249c65b0f17235073149d0033efcebe80095570"}, + {file = "pydantic_core-2.18.1-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:6395a4435fa26519fd96fdccb77e9d00ddae9dd6c742309bd0b5610609ad7fb2"}, + {file = "pydantic_core-2.18.1-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:2533ad2883f001efa72f3d0e733fb846710c3af6dcdd544fe5bf14fa5fe2d7db"}, + {file = "pydantic_core-2.18.1-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:b560b72ed4816aee52783c66854d96157fd8175631f01ef58e894cc57c84f0f6"}, + {file = "pydantic_core-2.18.1-cp39-none-win32.whl", hash = "sha256:582cf2cead97c9e382a7f4d3b744cf0ef1a6e815e44d3aa81af3ad98762f5a9b"}, + {file = "pydantic_core-2.18.1-cp39-none-win_amd64.whl", hash = "sha256:ca71d501629d1fa50ea7fa3b08ba884fe10cefc559f5c6c8dfe9036c16e8ae89"}, + {file = "pydantic_core-2.18.1-pp310-pypy310_pp73-macosx_10_12_x86_64.whl", hash = "sha256:e178e5b66a06ec5bf51668ec0d4ac8cfb2bdcb553b2c207d58148340efd00143"}, + {file = "pydantic_core-2.18.1-pp310-pypy310_pp73-macosx_11_0_arm64.whl", hash = "sha256:72722ce529a76a4637a60be18bd789d8fb871e84472490ed7ddff62d5fed620d"}, + {file = "pydantic_core-2.18.1-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:2fe0c1ce5b129455e43f941f7a46f61f3d3861e571f2905d55cdbb8b5c6f5e2c"}, + {file = "pydantic_core-2.18.1-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d4284c621f06a72ce2cb55f74ea3150113d926a6eb78ab38340c08f770eb9b4d"}, + {file = "pydantic_core-2.18.1-pp310-pypy310_pp73-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:1a0c3e718f4e064efde68092d9d974e39572c14e56726ecfaeebbe6544521f47"}, + {file = "pydantic_core-2.18.1-pp310-pypy310_pp73-musllinux_1_1_aarch64.whl", hash = "sha256:2027493cc44c23b598cfaf200936110433d9caa84e2c6cf487a83999638a96ac"}, + {file = "pydantic_core-2.18.1-pp310-pypy310_pp73-musllinux_1_1_x86_64.whl", hash = "sha256:76909849d1a6bffa5a07742294f3fa1d357dc917cb1fe7b470afbc3a7579d539"}, + {file = "pydantic_core-2.18.1-pp310-pypy310_pp73-win_amd64.whl", hash = "sha256:ee7ccc7fb7e921d767f853b47814c3048c7de536663e82fbc37f5eb0d532224b"}, + {file = "pydantic_core-2.18.1-pp39-pypy39_pp73-macosx_10_12_x86_64.whl", hash = "sha256:ee2794111c188548a4547eccc73a6a8527fe2af6cf25e1a4ebda2fd01cdd2e60"}, + {file = "pydantic_core-2.18.1-pp39-pypy39_pp73-macosx_11_0_arm64.whl", hash = "sha256:a139fe9f298dc097349fb4f28c8b81cc7a202dbfba66af0e14be5cfca4ef7ce5"}, + {file = "pydantic_core-2.18.1-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d074b07a10c391fc5bbdcb37b2f16f20fcd9e51e10d01652ab298c0d07908ee2"}, + {file = "pydantic_core-2.18.1-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:c69567ddbac186e8c0aadc1f324a60a564cfe25e43ef2ce81bcc4b8c3abffbae"}, + {file = "pydantic_core-2.18.1-pp39-pypy39_pp73-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:baf1c7b78cddb5af00971ad5294a4583188bda1495b13760d9f03c9483bb6203"}, + {file = "pydantic_core-2.18.1-pp39-pypy39_pp73-musllinux_1_1_aarch64.whl", hash = "sha256:2684a94fdfd1b146ff10689c6e4e815f6a01141781c493b97342cdc5b06f4d5d"}, + {file = "pydantic_core-2.18.1-pp39-pypy39_pp73-musllinux_1_1_x86_64.whl", hash = "sha256:73c1bc8a86a5c9e8721a088df234265317692d0b5cd9e86e975ce3bc3db62a59"}, + {file = "pydantic_core-2.18.1-pp39-pypy39_pp73-win_amd64.whl", hash = "sha256:e60defc3c15defb70bb38dd605ff7e0fae5f6c9c7cbfe0ad7868582cb7e844a6"}, + {file = "pydantic_core-2.18.1.tar.gz", hash = "sha256:de9d3e8717560eb05e28739d1b35e4eac2e458553a52a301e51352a7ffc86a35"}, ] [package.dependencies] @@ -598,13 +546,13 @@ typing-extensions = ">=4.6.0,<4.7.0 || >4.7.0" [[package]] name = "pyright" -version = "1.1.356" +version = "1.1.358" description = "Command line wrapper for pyright" optional = false python-versions = ">=3.7" files = [ - {file = "pyright-1.1.356-py3-none-any.whl", hash = "sha256:a101b0f375f93d7082f9046cfaa7ba15b7cf8e1939ace45e984c351f6e8feb99"}, - {file = "pyright-1.1.356.tar.gz", hash = "sha256:f05b8b29d06b96ed4a0885dad5a31d9dff691ca12b2f658249f583d5f2754021"}, + {file = "pyright-1.1.358-py3-none-any.whl", hash = "sha256:0995b6a95eb11bd26f093cd5dee3d5e7258441b1b94d4a171b5dc5b79a1d4f4e"}, + {file = "pyright-1.1.358.tar.gz", hash = "sha256:185524a8d52f6f14bbd3b290b92ad905f25b964dddc9e7148aad760bd35c9f60"}, ] [package.dependencies] @@ -715,28 +663,28 @@ files = [ [[package]] name = "ruff" -version = "0.0.285" -description = "An extremely fast Python linter, written in Rust." +version = "0.3.7" +description = "An extremely fast Python linter and code formatter, written in Rust." optional = false python-versions = ">=3.7" files = [ - {file = "ruff-0.0.285-py3-none-macosx_10_7_x86_64.whl", hash = "sha256:72a3a0936369b986b0e959f9090206ed3c18f9e5e439ea5b8e6867c6707aded5"}, - {file = "ruff-0.0.285-py3-none-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl", hash = "sha256:0d9ab6ad16742eb78919e0fba09f914f042409df40ad63423c34bb20d350162a"}, - {file = "ruff-0.0.285-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:6c48926156288b8ac005eb1db5e77c15e8a37309ae49d9fb6771d5cf5f777590"}, - {file = "ruff-0.0.285-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:1d2a60c102e7a5e147b58fc2cbea12a563c565383effc527c987ea2086a05742"}, - {file = "ruff-0.0.285-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:b02aae62f922d088bb01943e1dbd861688ada13d735b78b8348a7d90121fd292"}, - {file = "ruff-0.0.285-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:f572c4296d8c7ddd22c3204de4031965be524fdd1fdaaef273945932912b28c5"}, - {file = "ruff-0.0.285-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:80effdf4fe69763d69eb4ab9443e186fd09e668b59fe70ba4b49f4c077d15a1b"}, - {file = "ruff-0.0.285-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:5977ce304da35c263f5e082901bd7ac0bd2be845a8fcfd1a29e4d6680cddb307"}, - {file = "ruff-0.0.285-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:72a087712d474fa17b915d7cb9ef807e1256182b12ddfafb105eb00aeee48d1a"}, - {file = "ruff-0.0.285-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:7ce67736cd8dfe97162d1e7adfc2d9a1bac0efb9aaaff32e4042c7cde079f54b"}, - {file = "ruff-0.0.285-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:5473a4c6cac34f583bff08c5f63b8def5599a0ea4dc96c0302fbd2cc0b3ecbad"}, - {file = "ruff-0.0.285-py3-none-musllinux_1_2_i686.whl", hash = "sha256:e6b1c961d608d373a032f047a20bf3c55ad05f56c32e7b96dcca0830a2a72348"}, - {file = "ruff-0.0.285-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:2933cc9631f453305399c7b8fb72b113ad76b49ae1d7103cc4afd3a423bed164"}, - {file = "ruff-0.0.285-py3-none-win32.whl", hash = "sha256:770c5eb6376de024111443022cda534fb28980a9dd3b4abc83992a8770167ba6"}, - {file = "ruff-0.0.285-py3-none-win_amd64.whl", hash = "sha256:a8c6ad6b9cd77489bf6d1510950cbbe47a843aa234adff0960bae64bd06c3b6d"}, - {file = "ruff-0.0.285-py3-none-win_arm64.whl", hash = "sha256:de44fbc6c3b25fccee473ddf851416fd4e246fc6027b2197c395b1b3b3897921"}, - {file = "ruff-0.0.285.tar.gz", hash = "sha256:45866048d1dcdcc80855998cb26c4b2b05881f9e043d2e3bfe1aa36d9a2e8f28"}, + {file = "ruff-0.3.7-py3-none-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl", hash = "sha256:0e8377cccb2f07abd25e84fc5b2cbe48eeb0fea9f1719cad7caedb061d70e5ce"}, + {file = "ruff-0.3.7-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:15a4d1cc1e64e556fa0d67bfd388fed416b7f3b26d5d1c3e7d192c897e39ba4b"}, + {file = "ruff-0.3.7-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d28bdf3d7dc71dd46929fafeec98ba89b7c3550c3f0978e36389b5631b793663"}, + {file = "ruff-0.3.7-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:379b67d4f49774ba679593b232dcd90d9e10f04d96e3c8ce4a28037ae473f7bb"}, + {file = "ruff-0.3.7-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:c060aea8ad5ef21cdfbbe05475ab5104ce7827b639a78dd55383a6e9895b7c51"}, + {file = "ruff-0.3.7-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:ebf8f615dde968272d70502c083ebf963b6781aacd3079081e03b32adfe4d58a"}, + {file = "ruff-0.3.7-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:d48098bd8f5c38897b03604f5428901b65e3c97d40b3952e38637b5404b739a2"}, + {file = "ruff-0.3.7-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:da8a4fda219bf9024692b1bc68c9cff4b80507879ada8769dc7e985755d662ea"}, + {file = "ruff-0.3.7-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6c44e0149f1d8b48c4d5c33d88c677a4aa22fd09b1683d6a7ff55b816b5d074f"}, + {file = "ruff-0.3.7-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:3050ec0af72b709a62ecc2aca941b9cd479a7bf2b36cc4562f0033d688e44fa1"}, + {file = "ruff-0.3.7-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:a29cc38e4c1ab00da18a3f6777f8b50099d73326981bb7d182e54a9a21bb4ff7"}, + {file = "ruff-0.3.7-py3-none-musllinux_1_2_i686.whl", hash = "sha256:5b15cc59c19edca917f51b1956637db47e200b0fc5e6e1878233d3a938384b0b"}, + {file = "ruff-0.3.7-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:e491045781b1e38b72c91247cf4634f040f8d0cb3e6d3d64d38dcf43616650b4"}, + {file = "ruff-0.3.7-py3-none-win32.whl", hash = "sha256:bc931de87593d64fad3a22e201e55ad76271f1d5bfc44e1a1887edd0903c7d9f"}, + {file = "ruff-0.3.7-py3-none-win_amd64.whl", hash = "sha256:5ef0e501e1e39f35e03c2acb1d1238c595b8bb36cf7a170e7c1df1b73da00e74"}, + {file = "ruff-0.3.7-py3-none-win_arm64.whl", hash = "sha256:789e144f6dc7019d1f92a812891c645274ed08af6037d11fc65fcbc183b7d59f"}, + {file = "ruff-0.3.7.tar.gz", hash = "sha256:d5c1aebee5162c2226784800ae031f660c350e7a3402c4d1f8ea4e97e232e3ba"}, ] [[package]] @@ -752,30 +700,19 @@ files = [ [[package]] name = "setuptools" -version = "68.2.2" +version = "69.2.0" description = "Easily download, build, install, upgrade, and uninstall Python packages" optional = false python-versions = ">=3.8" files = [ - {file = "setuptools-68.2.2-py3-none-any.whl", hash = "sha256:b454a35605876da60632df1a60f736524eb73cc47bbc9f3f1ef1b644de74fd2a"}, - {file = "setuptools-68.2.2.tar.gz", hash = "sha256:4ac1475276d2f1c48684874089fefcd83bd7162ddaafb81fac866ba0db282a87"}, + {file = "setuptools-69.2.0-py3-none-any.whl", hash = "sha256:c21c49fb1042386df081cb5d86759792ab89efca84cf114889191cd09aacc80c"}, + {file = "setuptools-69.2.0.tar.gz", hash = "sha256:0ff4183f8f42cd8fa3acea16c45205521a4ef28f73c6391d8a25e92893134f2e"}, ] [package.extras] -docs = ["furo", "jaraco.packaging (>=9.3)", "jaraco.tidelift (>=1.4)", "pygments-github-lexers (==0.0.5)", "rst.linker (>=1.9)", "sphinx (>=3.5)", "sphinx-favicon", "sphinx-hoverxref (<2)", "sphinx-inline-tabs", "sphinx-lint", "sphinx-notfound-page (>=1,<2)", "sphinx-reredirects", "sphinxcontrib-towncrier"] -testing = ["build[virtualenv]", "filelock (>=3.4.0)", "flake8-2020", "ini2toml[lite] (>=0.9)", "jaraco.develop (>=7.21)", "jaraco.envs (>=2.2)", "jaraco.path (>=3.2.0)", "pip (>=19.1)", "pytest (>=6)", "pytest-black (>=0.3.7)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=2.2)", "pytest-mypy (>=0.9.1)", "pytest-perf", "pytest-ruff", "pytest-timeout", "pytest-xdist", "tomli-w (>=1.0.0)", "virtualenv (>=13.0.0)", "wheel"] -testing-integration = ["build[virtualenv] (>=1.0.3)", "filelock (>=3.4.0)", "jaraco.envs (>=2.2)", "jaraco.path (>=3.2.0)", "packaging (>=23.1)", "pytest", "pytest-enabler", "pytest-xdist", "tomli", "virtualenv (>=13.0.0)", "wheel"] - -[[package]] -name = "sortedcontainers" -version = "2.4.0" -description = "Sorted Containers -- Sorted List, Sorted Dict, Sorted Set" -optional = false -python-versions = "*" -files = [ - {file = "sortedcontainers-2.4.0-py2.py3-none-any.whl", hash = "sha256:a163dcaede0f1c021485e957a39245190e74249897e2ae4b2aa38595db237ee0"}, - {file = "sortedcontainers-2.4.0.tar.gz", hash = "sha256:25caa5a06cc30b6b83d11423433f65d1f9d76c4c6a0c90e3379eaa43b9bfdb88"}, -] +docs = ["furo", "jaraco.packaging (>=9.3)", "jaraco.tidelift (>=1.4)", "pygments-github-lexers (==0.0.5)", "rst.linker (>=1.9)", "sphinx (<7.2.5)", "sphinx (>=3.5)", "sphinx-favicon", "sphinx-inline-tabs", "sphinx-lint", "sphinx-notfound-page (>=1,<2)", "sphinx-reredirects", "sphinxcontrib-towncrier"] +testing = ["build[virtualenv]", "filelock (>=3.4.0)", "importlib-metadata", "ini2toml[lite] (>=0.9)", "jaraco.develop (>=7.21)", "jaraco.envs (>=2.2)", "jaraco.path (>=3.2.0)", "mypy (==1.9)", "packaging (>=23.2)", "pip (>=19.1)", "pytest (>=6)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=2.2)", "pytest-home (>=0.5)", "pytest-mypy (>=0.9.1)", "pytest-perf", "pytest-ruff (>=0.2.1)", "pytest-timeout", "pytest-xdist (>=3)", "tomli", "tomli-w (>=1.0.0)", "virtualenv (>=13.0.0)", "wheel"] +testing-integration = ["build[virtualenv] (>=1.0.3)", "filelock (>=3.4.0)", "jaraco.envs (>=2.2)", "jaraco.path (>=3.2.0)", "packaging (>=23.2)", "pytest", "pytest-enabler", "pytest-xdist", "tomli", "virtualenv (>=13.0.0)", "wheel"] [[package]] name = "tomli" @@ -790,16 +727,16 @@ files = [ [[package]] name = "typing-extensions" -version = "4.10.0" +version = "4.11.0" description = "Backported and Experimental Type Hints for Python 3.8+" optional = false python-versions = ">=3.8" files = [ - {file = "typing_extensions-4.10.0-py3-none-any.whl", hash = "sha256:69b1a937c3a517342112fb4c6df7e72fc39a38e7891a5730ed4985b5214b5475"}, - {file = "typing_extensions-4.10.0.tar.gz", hash = "sha256:b0abd7c89e8fb96f98db18d86106ff1d90ab692004eb746cf6eda2682f91b3cb"}, + {file = "typing_extensions-4.11.0-py3-none-any.whl", hash = "sha256:c1f94d72897edaf4ce775bb7558d5b79d8126906a14ea5ed1635921406c0387a"}, + {file = "typing_extensions-4.11.0.tar.gz", hash = "sha256:83f085bd5ca59c80295fc2a82ab5dac679cbe02b9f33f7d83af68e241bea51b0"}, ] [metadata] lock-version = "2.0" python-versions = ">=3.9, <3.13" -content-hash = "c2882f1697fbacd7ce3ad45b41d7eff3f46a7bb6cccb0f2d478e94f6220efc71" +content-hash = "5ec660de4dc87da3469bf6720af6df9f7cfc55b4b6a9bd028d8fdfea22431251" diff --git a/pydantic_numpy/helper/annotation.py b/pydantic_numpy/helper/annotation.py index fe15669..01e36b5 100644 --- a/pydantic_numpy/helper/annotation.py +++ b/pydantic_numpy/helper/annotation.py @@ -283,18 +283,18 @@ def _deserialize_numpy_array_from_data_dict(data_dict: NumpyArrayTypeData) -> np # IN_THE_FUTURE: Only works with 3.11 and above # @validate_call -# def _dimension_type_from_depth(depth: PositiveInt) -> type[tuple[Any, ...]]: -# return tuple[*[Any] * depth] # type: ignore - - -_dimensions_to_shape_type: Final[dict[PositiveInt, type[tuple[Any, ...]]]] = { - 1: tuple[Any], - 2: tuple[Any, Any], - 3: tuple[Any, Any, Any], - 4: tuple[Any, Any, Any, Any], - 5: tuple[Any, Any, Any, Any, Any], - 6: tuple[Any, Any, Any, Any, Any, Any], - 7: tuple[Any, Any, Any, Any, Any, Any, Any], +# def _dimension_type_from_depth(depth: PositiveInt) -> type[tuple[int, ...]]: +# return tuple[*[int] * depth] # type: ignore + + +_dimensions_to_shape_type: Final[dict[PositiveInt, type[tuple[int, ...]]]] = { + 1: tuple[int], # type: ignore[dict-item] + 2: tuple[int, int], # type: ignore[dict-item] + 3: tuple[int, int, int], # type: ignore[dict-item] + 4: tuple[int, int, int, int], # type: ignore[dict-item] + 5: tuple[int, int, int, int, int], # type: ignore[dict-item] + 6: tuple[int, int, int, int, int, int], # type: ignore[dict-item] + 7: tuple[int, int, int, int, int, int, int], # type: ignore[dict-item] } diff --git a/pyproject.toml b/pyproject.toml index 67bac8a..1158d17 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -29,14 +29,12 @@ semver = "^3.0.1" [tool.poetry.group.dev.dependencies] pytest = "^7.4.0" parameterized = "^0.9.0" -hypothesis = "^6.82.0" orjson = "*" -setuptools = "^68.0.0" [tool.poetry.group.format.dependencies] black = "^23.7.0" isort = "^5.12.0" -ruff = "^0.0.285" +ruff = "*" [tool.poetry.group.typecheck.dependencies] mypy = "*" @@ -44,7 +42,6 @@ pyright = "^1.1.338" [tool.pytest.ini_options] filterwarnings = [ - "ignore::hypothesis.errors.NonInteractiveExampleWarning", "ignore:invalid value encountered in multiply:RuntimeWarning", ] @@ -57,10 +54,11 @@ profile = "black" [tool.ruff] line-length = 120 -ignore-init-module-imports = true -ignore = ["F403", "F405"] +lint.ignore-init-module-imports = true +lint.ignore = ["F403", "F405"] [tool.pyright] +include = ["pydantic_numpy/**", "tests/**"] reportUnsupportedDunderAll = false [build-system] diff --git a/tests/helper/cache.py b/tests/helper/cache.py index 1781b33..38024ae 100644 --- a/tests/helper/cache.py +++ b/tests/helper/cache.py @@ -1,36 +1,11 @@ -from functools import cache -from typing import Optional +from functools import lru_cache -import numpy as np -from hypothesis.extra.numpy import arrays -from hypothesis.strategies import floats from pydantic import BaseModel -from pydantic_numpy.helper.typing import SupportedDTypes - -@cache -def cached_calculation(array_type_hint) -> type[BaseModel]: +@lru_cache +def get_numpy_type_model(array_type_hint) -> type[BaseModel]: class ModelForTesting(BaseModel): array_field: array_type_hint return ModelForTesting - - -@cache -def cached_hyp_array(numpy_dtype: SupportedDTypes, dimensions: Optional[int] = None, *, _axis_length: int = 1): - if np.issubdtype(numpy_dtype, np.floating): - if numpy_dtype == np.float16: - width = 16 - elif numpy_dtype == np.float32: - width = 32 - elif numpy_dtype in (np.longdouble, np.float64): - width = 64 - else: - raise RuntimeError - - element_strategy = floats(allow_infinity=False, allow_nan=False, width=width) - else: - element_strategy = None - - return arrays(numpy_dtype, tuple(_axis_length for _ in range(dimensions or 1)), elements=element_strategy) diff --git a/tests/helper/groups.py b/tests/helper/groups.py deleted file mode 100644 index 843b8f4..0000000 --- a/tests/helper/groups.py +++ /dev/null @@ -1,210 +0,0 @@ -import numpy as np - -from pydantic_numpy.typing import * - -supported_data_types = ( - np.int64, - np.int32, - np.int16, - np.int8, - np.uint64, - np.uint32, - np.uint16, - np.uint8, - np.longdouble, - np.float64, - np.float32, - np.float16, - np.clongdouble, - np.complex128, - np.complex64, - # np.datetime64, - np.timedelta64, -) - -data_type_1d_array_typing_dimensions = [ - (np.int64, Np1DArrayInt64, 1), - (np.int32, Np1DArrayInt32, 1), - (np.int16, Np1DArrayInt16, 1), - (np.int8, Np1DArrayInt8, 1), - (np.uint64, Np1DArrayUint64, 1), - (np.uint32, Np1DArrayUint32, 1), - (np.uint16, Np1DArrayUint16, 1), - (np.uint8, Np1DArrayUint8, 1), - (np.longdouble, Np1DArrayFpLongDouble, 1), - (np.float64, Np1DArrayFp64, 1), - (np.float32, Np1DArrayFp32, 1), - (np.float16, Np1DArrayFp16, 1), - (np.clongdouble, Np1DArrayComplexLongDouble, 1), - (np.complex128, Np1DArrayComplex128, 1), - (np.complex64, Np1DArrayComplex64, 1), - (bool, Np1DArrayBool, 1), - # (np.datetime64, Np1DArrayDatetime64, 1), - (np.timedelta64, Np1DArrayTimedelta64, 1), -] -data_type_2d_array_typing_dimensions = [ - (np.int64, Np2DArrayInt64, 2), - (np.int32, Np2DArrayInt32, 2), - (np.int16, Np2DArrayInt16, 2), - (np.int8, Np2DArrayInt8, 2), - (np.uint64, Np2DArrayUint64, 2), - (np.uint32, Np2DArrayUint32, 2), - (np.uint16, Np2DArrayUint16, 2), - (np.uint8, Np2DArrayUint8, 2), - (np.longdouble, Np2DArrayFpLongDouble, 2), - (np.float64, Np2DArrayFp64, 2), - (np.float32, Np2DArrayFp32, 2), - (np.float16, Np2DArrayFp16, 2), - (np.clongdouble, Np2DArrayComplexLongDouble, 2), - (np.complex128, Np2DArrayComplex128, 2), - (np.complex64, Np2DArrayComplex64, 2), - (bool, Np2DArrayBool, 2), - # (np.datetime64, Np2DArrayDatetime64, 2), - (np.timedelta64, Np2DArrayTimedelta64, 2), -] -data_type_3d_array_typing_dimensions = [ - (np.int64, Np3DArrayInt64, 3), - (np.int32, Np3DArrayInt32, 3), - (np.int16, Np3DArrayInt16, 3), - (np.int8, Np3DArrayInt8, 3), - (np.uint64, Np3DArrayUint64, 3), - (np.uint32, Np3DArrayUint32, 3), - (np.uint16, Np3DArrayUint16, 3), - (np.uint8, Np3DArrayUint8, 3), - (np.longdouble, Np3DArrayFpLongDouble, 3), - (np.float64, Np3DArrayFp64, 3), - (np.float32, Np3DArrayFp32, 3), - (np.float16, Np3DArrayFp16, 3), - (np.clongdouble, Np3DArrayComplexLongDouble, 3), - (np.complex128, Np3DArrayComplex128, 3), - (np.complex64, Np3DArrayComplex64, 3), - (bool, Np3DArrayBool, 3), - # (np.datetime64, Np3DArrayDatetime64, 3), - (np.timedelta64, Np3DArrayTimedelta64, 3), -] - -data_type_nd_array_typing_dimensions_without_complex = [ - (np.int64, NpNDArrayInt64, None), - (np.int32, NpNDArrayInt32, None), - (np.int16, NpNDArrayInt16, None), - (np.int8, NpNDArrayInt8, None), - (np.uint64, NpNDArrayUint64, None), - (np.uint32, NpNDArrayUint32, None), - (np.uint16, NpNDArrayUint16, None), - (np.uint8, NpNDArrayUint8, None), - (np.longdouble, NpNDArrayFpLongDouble, None), - (np.float64, NpNDArrayFp64, None), - (np.float32, NpNDArrayFp32, None), - (np.float16, NpNDArrayFp16, None), - (bool, NpNDArrayBool, None), - (np.datetime64, NpNDArrayDatetime64, None), - (np.timedelta64, NpNDArrayTimedelta64, None), -] -data_type_nd_array_typing_dimensions = [ - *data_type_nd_array_typing_dimensions_without_complex, - (np.clongdouble, NpNDArrayComplexLongDouble, None), - (np.complex128, NpNDArrayComplex128, None), - (np.complex64, NpNDArrayComplex64, None), -] - -data_type_array_typing_dimensions = [ - *data_type_1d_array_typing_dimensions, - *data_type_2d_array_typing_dimensions, - *data_type_3d_array_typing_dimensions, - *data_type_nd_array_typing_dimensions, -] - -# Data type strict -strict_data_type_1d_array_typing_dimensions = [ - (np.int64, NpStrict1DArrayInt64, 1), - (np.int32, NpStrict1DArrayInt32, 1), - (np.int16, NpStrict1DArrayInt16, 1), - (np.int8, NpStrict1DArrayInt8, 1), - (np.uint64, NpStrict1DArrayUint64, 1), - (np.uint32, NpStrict1DArrayUint32, 1), - (np.uint16, NpStrict1DArrayUint16, 1), - (np.uint8, NpStrict1DArrayUint8, 1), - (np.longdouble, NpStrict1DArrayFpLongDouble, 1), - (np.float64, NpStrict1DArrayFp64, 1), - (np.float32, NpStrict1DArrayFp32, 1), - (np.float16, NpStrict1DArrayFp16, 1), - (np.clongdouble, NpStrict1DArrayComplexLongDouble, 1), - (np.complex128, NpStrict1DArrayComplex128, 1), - (np.complex64, NpStrict1DArrayComplex64, 1), - (bool, NpStrict1DArrayBool, 1), - # (np.datetime64, NpStrict1DArrayDatetime64, 1), - (np.timedelta64, NpStrict1DArrayTimedelta64, 1), -] -strict_data_type_2d_array_typing_dimensions = [ - (np.int64, NpStrict2DArrayInt64, 2), - (np.int32, NpStrict2DArrayInt32, 2), - (np.int16, NpStrict2DArrayInt16, 2), - (np.int8, NpStrict2DArrayInt8, 2), - (np.uint64, NpStrict2DArrayUint64, 2), - (np.uint32, NpStrict2DArrayUint32, 2), - (np.uint16, NpStrict2DArrayUint16, 2), - (np.uint8, NpStrict2DArrayUint8, 2), - (np.longdouble, NpStrict2DArrayFpLongDouble, 2), - (np.float64, NpStrict2DArrayFp64, 2), - (np.float32, NpStrict2DArrayFp32, 2), - (np.float16, NpStrict2DArrayFp16, 2), - (np.clongdouble, NpStrict2DArrayComplexLongDouble, 2), - (np.complex128, NpStrict2DArrayComplex128, 2), - (np.complex64, NpStrict2DArrayComplex64, 2), - (bool, NpStrict2DArrayBool, 2), - # (np.datetime64, NpStrict2DArrayDatetime64, 2), - (np.timedelta64, NpStrict2DArrayTimedelta64, 2), -] -strict_data_type_3d_array_typing_dimensions = [ - (np.int64, NpStrict3DArrayInt64, 3), - (np.int32, NpStrict3DArrayInt32, 3), - (np.int16, NpStrict3DArrayInt16, 3), - (np.int8, NpStrict3DArrayInt8, 3), - (np.uint64, NpStrict3DArrayUint64, 3), - (np.uint32, NpStrict3DArrayUint32, 3), - (np.uint16, NpStrict3DArrayUint16, 3), - (np.uint8, NpStrict3DArrayUint8, 3), - (np.longdouble, NpStrict3DArrayFpLongDouble, 3), - (np.float64, NpStrict3DArrayFp64, 3), - (np.float32, NpStrict3DArrayFp32, 3), - (np.float16, NpStrict3DArrayFp16, 3), - (np.clongdouble, NpStrict3DArrayComplexLongDouble, 3), - (np.complex128, NpStrict3DArrayComplex128, 3), - (np.complex64, NpStrict3DArrayComplex64, 3), - (bool, NpStrict3DArrayBool, 3), - # (np.datetime64, NpStrict3DArrayDatetime64, 3), - (np.timedelta64, NpStrict3DArrayTimedelta64, 3), -] -strict_data_type_nd_array_typing_dimensions = [ - (np.int64, NpStrictNDArrayInt64, None), - (np.int32, NpStrictNDArrayInt32, None), - (np.int16, NpStrictNDArrayInt16, None), - (np.int8, NpStrictNDArrayInt8, None), - (np.uint64, NpStrictNDArrayUint64, None), - (np.uint32, NpStrictNDArrayUint32, None), - (np.uint16, NpStrictNDArrayUint16, None), - (np.uint8, NpStrictNDArrayUint8, None), - (np.longdouble, NpStrictNDArrayFpLongDouble, None), - (np.float64, NpStrictNDArrayFp64, None), - (np.float32, NpStrictNDArrayFp32, None), - (np.float16, NpStrictNDArrayFp16, None), - (np.clongdouble, NpStrictNDArrayComplexLongDouble, None), - (np.complex128, NpStrictNDArrayComplex128, None), - (np.complex64, NpStrictNDArrayComplex64, None), - (bool, NpStrictNDArrayBool, None), - # (np.datetime64, NpStrictNDArrayDatetime64, None), - (np.timedelta64, NpStrictNDArrayTimedelta64, None), -] - -strict_data_type_array_typing_dimensions = [ - *strict_data_type_1d_array_typing_dimensions, - *strict_data_type_2d_array_typing_dimensions, - *strict_data_type_3d_array_typing_dimensions, - *strict_data_type_nd_array_typing_dimensions, -] - -dimension_testing_group = [ - (np.int64, Np1DArrayInt64, 1), - (np.int64, Np2DArrayInt64, 2), - (np.int64, Np3DArrayInt64, 3), -] diff --git a/tests/helper/testing_groups.py b/tests/helper/testing_groups.py new file mode 100644 index 0000000..1572542 --- /dev/null +++ b/tests/helper/testing_groups.py @@ -0,0 +1,199 @@ +import numpy as np + +from pydantic_numpy.typing import * + +supported_data_types = ( + (np.array([0]), np.int64), + (np.array([0], dtype=np.int32), np.int32), + (np.array([0], dtype=np.int16), np.int16), + (np.array([0], dtype=np.int8), np.int8), + (np.array([0], dtype=np.uint64), np.uint64), + (np.array([0], dtype=np.uint32), np.uint32), + (np.array([0], dtype=np.uint16), np.uint16), + (np.array([0], dtype=np.uint8), np.uint8), + (np.array([0.0]), np.float64), + (np.array([0.0], dtype=np.float32), np.float32), + (np.array([0.0], dtype=np.float16), np.float16), + (np.array([0.0 + 0.0j]), np.complex128), + (np.array([0.0 + 0.0j], dtype=np.complex64), np.complex64), + (np.array([False]), np.bool_), + (np.array([0], dtype=np.timedelta64), np.timedelta64), +) + +data_type_1d_array_typing_dimensions = [ + (np.array([0]), np.int64, Np1DArrayInt64, 1), + (np.array([0], dtype=np.int32), np.int32, Np1DArrayInt32, 1), + (np.array([0], dtype=np.int16), np.int16, Np1DArrayInt16, 1), + (np.array([0], dtype=np.int8), np.int8, Np1DArrayInt8, 1), + (np.array([0], dtype=np.uint64), np.uint64, Np1DArrayUint64, 1), + (np.array([0], dtype=np.uint32), np.uint32, Np1DArrayUint32, 1), + (np.array([0], dtype=np.uint16), np.uint16, Np1DArrayUint16, 1), + (np.array([0], dtype=np.uint8), np.uint8, Np1DArrayUint8, 1), + (np.array([0.0], dtype=np.float128), np.float128, Np1DArrayFpLongDouble, 1), + (np.array([0.0]), np.float64, Np1DArrayFp64, 1), + (np.array([0.0], dtype=np.float32), np.float32, Np1DArrayFp32, 1), + (np.array([0.0], dtype=np.float16), np.float16, Np1DArrayFp16, 1), + (np.array([0.0 + 0.0j], dtype=np.complex256), np.complex256, Np1DArrayComplexLongDouble, 1), + (np.array([0.0 + 0.0j]), np.complex128, Np1DArrayComplex128, 1), + (np.array([0.0 + 0.0j], dtype=np.complex64), np.complex64, Np1DArrayComplex64, 1), + (np.array([False]), np.bool_, Np1DArrayBool, 1), + (np.array([0], dtype=np.timedelta64), np.timedelta64, Np1DArrayTimedelta64, 1), +] +data_type_2d_array_typing_dimensions = [ + (np.array([[0]]), np.int64, Np2DArrayInt64, 2), + (np.array([[0]], dtype=np.int32), np.int32, Np2DArrayInt32, 2), + (np.array([[0]], dtype=np.int16), np.int16, Np2DArrayInt16, 2), + (np.array([[0]], dtype=np.int8), np.int8, Np2DArrayInt8, 2), + (np.array([[0]], dtype=np.uint64), np.uint64, Np2DArrayUint64, 2), + (np.array([[0]], dtype=np.uint32), np.uint32, Np2DArrayUint32, 2), + (np.array([[0]], dtype=np.uint16), np.uint16, Np2DArrayUint16, 2), + (np.array([[0]], dtype=np.uint8), np.uint8, Np2DArrayUint8, 2), + (np.array([[0.0]], dtype=np.float128), np.float128, Np2DArrayFpLongDouble, 2), + (np.array([[0.0]]), np.float64, Np2DArrayFp64, 2), + (np.array([[0.0]], dtype=np.float32), np.float32, Np2DArrayFp32, 2), + (np.array([[0.0]], dtype=np.float16), np.float16, Np2DArrayFp16, 2), + (np.array([[0.0 + 0.0j]], dtype=np.complex256), np.complex256, Np2DArrayComplexLongDouble, 2), + (np.array([[0.0 + 0.0j]]), np.complex128, Np2DArrayComplex128, 2), + (np.array([[0.0 + 0.0j]], dtype=np.complex64), np.complex64, Np2DArrayComplex64, 2), + (np.array([[False]]), np.bool_, Np2DArrayBool, 2), + (np.array([[0]], dtype=np.timedelta64), np.timedelta64, Np2DArrayTimedelta64, 2), +] +data_type_3d_array_typing_dimensions = [ + (np.array([[[0]]]), np.int64, Np3DArrayInt64, 3), + (np.array([[[0]]], dtype=np.int32), np.int32, Np3DArrayInt32, 3), + (np.array([[[0]]], dtype=np.int16), np.int16, Np3DArrayInt16, 3), + (np.array([[[0]]], dtype=np.int8), np.int8, Np3DArrayInt8, 3), + (np.array([[[0]]], dtype=np.uint64), np.uint64, Np3DArrayUint64, 3), + (np.array([[[0]]], dtype=np.uint32), np.uint32, Np3DArrayUint32, 3), + (np.array([[[0]]], dtype=np.uint16), np.uint16, Np3DArrayUint16, 3), + (np.array([[[0]]], dtype=np.uint8), np.uint8, Np3DArrayUint8, 3), + (np.array([[[0.0]]], dtype=np.float128), np.float128, Np3DArrayFpLongDouble, 3), + (np.array([[[0.0]]]), np.float64, Np3DArrayFp64, 3), + (np.array([[[0.0]]], dtype=np.float32), np.float32, Np3DArrayFp32, 3), + (np.array([[[0.0]]], dtype=np.float16), np.float16, Np3DArrayFp16, 3), + (np.array([[[0.0 + 0.0j]]], dtype=np.complex256), np.complex256, Np3DArrayComplexLongDouble, 3), + (np.array([[[0.0 + 0.0j]]]), np.complex128, Np3DArrayComplex128, 3), + (np.array([[[0.0 + 0.0j]]], dtype=np.complex64), np.complex64, Np3DArrayComplex64, 3), + (np.array([[[False]]]), np.bool_, Np3DArrayBool, 3), + (np.array([[[0]]], dtype=np.timedelta64), np.timedelta64, Np3DArrayTimedelta64, 3), +] +data_type_nd_array_typing_dimensions_without_complex = [ + (np.array([0]), np.int64, NpNDArrayInt64, None), + (np.array([0], dtype=np.int32), np.int32, NpNDArrayInt32, None), + (np.array([0], dtype=np.int16), np.int16, NpNDArrayInt16, None), + (np.array([0], dtype=np.int8), np.int8, NpNDArrayInt8, None), + (np.array([0], dtype=np.uint64), np.uint64, NpNDArrayUint64, None), + (np.array([0], dtype=np.uint32), np.uint32, NpNDArrayUint32, None), + (np.array([0], dtype=np.uint16), np.uint16, NpNDArrayUint16, None), + (np.array([0], dtype=np.uint8), np.uint8, NpNDArrayUint8, None), + (np.array([0.0], dtype=np.float128), np.float128, NpNDArrayFpLongDouble, None), + (np.array([0.0]), np.float64, NpNDArrayFp64, None), + (np.array([0.0], dtype=np.float32), np.float32, NpNDArrayFp32, None), + (np.array([0.0], dtype=np.float16), np.float16, NpNDArrayFp16, None), + (np.array([False]), np.bool_, NpNDArrayBool, None), + (np.array([0], dtype=np.timedelta64), np.timedelta64, NpNDArrayTimedelta64, None), +] + +data_type_nd_array_typing_dimensions = [ + *data_type_nd_array_typing_dimensions_without_complex, + (np.array([0.0 + 0.0j], dtype=np.complex256), np.complex256, NpNDArrayComplexLongDouble, None), + (np.array([0.0 + 0.0j]), np.complex128, NpNDArrayComplex128, None), + (np.array([0.0 + 0.0j], dtype=np.complex64), np.complex64, NpNDArrayComplex64, None), +] + +data_type_array_typing_dimensions = [ + *data_type_1d_array_typing_dimensions, + *data_type_2d_array_typing_dimensions, + *data_type_3d_array_typing_dimensions, + *data_type_nd_array_typing_dimensions, +] + +# Data type strict +strict_data_type_1d_array_typing_dimensions = [ + (np.array([0]), np.int64, NpStrict1DArrayInt64, 1), + (np.array([0], dtype=np.int32), np.int32, NpStrict1DArrayInt32, 1), + (np.array([0], dtype=np.int16), np.int16, NpStrict1DArrayInt16, 1), + (np.array([0], dtype=np.int8), np.int8, NpStrict1DArrayInt8, 1), + (np.array([0], dtype=np.uint64), np.uint64, NpStrict1DArrayUint64, 1), + (np.array([0], dtype=np.uint32), np.uint32, NpStrict1DArrayUint32, 1), + (np.array([0], dtype=np.uint16), np.uint16, NpStrict1DArrayUint16, 1), + (np.array([0], dtype=np.uint8), np.uint8, NpStrict1DArrayUint8, 1), + (np.array([0.0], dtype=np.float128), np.float128, NpStrict1DArrayFpLongDouble, 1), + (np.array([0.0]), np.float64, NpStrict1DArrayFp64, 1), + (np.array([0.0], dtype=np.float32), np.float32, NpStrict1DArrayFp32, 1), + (np.array([0.0], dtype=np.float16), np.float16, NpStrict1DArrayFp16, 1), + (np.array([0.0 + 0.0j], dtype=np.complex256), np.complex256, NpStrict1DArrayComplexLongDouble, 1), + (np.array([0.0 + 0.0j]), np.complex128, NpStrict1DArrayComplex128, 1), + (np.array([0.0 + 0.0j], dtype=np.complex64), np.complex64, NpStrict1DArrayComplex64, 1), + (np.array([False]), np.bool_, NpStrict1DArrayBool, 1), + (np.array([0], dtype=np.timedelta64), np.timedelta64, NpStrict1DArrayTimedelta64, 1), +] +strict_data_type_2d_array_typing_dimensions = [ + (np.array([[0]]), np.int64, NpStrict2DArrayInt64, 2), + (np.array([[0]], dtype=np.int32), np.int32, NpStrict2DArrayInt32, 2), + (np.array([[0]], dtype=np.int16), np.int16, NpStrict2DArrayInt16, 2), + (np.array([[0]], dtype=np.int8), np.int8, NpStrict2DArrayInt8, 2), + (np.array([[0]], dtype=np.uint64), np.uint64, NpStrict2DArrayUint64, 2), + (np.array([[0]], dtype=np.uint32), np.uint32, NpStrict2DArrayUint32, 2), + (np.array([[0]], dtype=np.uint16), np.uint16, NpStrict2DArrayUint16, 2), + (np.array([[0]], dtype=np.uint8), np.uint8, NpStrict2DArrayUint8, 2), + (np.array([[0.0]], dtype=np.float128), np.float128, NpStrict2DArrayFpLongDouble, 2), + (np.array([[0.0]]), np.float64, NpStrict2DArrayFp64, 2), + (np.array([[0.0]], dtype=np.float32), np.float32, NpStrict2DArrayFp32, 2), + (np.array([[0.0]], dtype=np.float16), np.float16, NpStrict2DArrayFp16, 2), + (np.array([[0.0 + 0.0j]], dtype=np.complex256), np.complex256, NpStrict2DArrayComplexLongDouble, 2), + (np.array([[0.0 + 0.0j]]), np.complex128, NpStrict2DArrayComplex128, 2), + (np.array([[0.0 + 0.0j]], dtype=np.complex64), np.complex64, NpStrict2DArrayComplex64, 2), + (np.array([[False]]), np.bool_, NpStrict2DArrayBool, 2), + (np.array([[0]], dtype=np.timedelta64), np.timedelta64, NpStrict2DArrayTimedelta64, 2), +] +strict_data_type_3d_array_typing_dimensions = [ + (np.array([[[0]]]), np.int64, NpStrict3DArrayInt64, 3), + (np.array([[[0]]], dtype=np.int32), np.int32, NpStrict3DArrayInt32, 3), + (np.array([[[0]]], dtype=np.int16), np.int16, NpStrict3DArrayInt16, 3), + (np.array([[[0]]], dtype=np.int8), np.int8, NpStrict3DArrayInt8, 3), + (np.array([[[0]]], dtype=np.uint64), np.uint64, NpStrict3DArrayUint64, 3), + (np.array([[[0]]], dtype=np.uint32), np.uint32, NpStrict3DArrayUint32, 3), + (np.array([[[0]]], dtype=np.uint16), np.uint16, NpStrict3DArrayUint16, 3), + (np.array([[[0]]], dtype=np.uint8), np.uint8, NpStrict3DArrayUint8, 3), + (np.array([[[0.0]]], dtype=np.float128), np.float128, NpStrict3DArrayFpLongDouble, 3), + (np.array([[[0.0]]]), np.float64, NpStrict3DArrayFp64, 3), + (np.array([[[0.0]]], dtype=np.float32), np.float32, NpStrict3DArrayFp32, 3), + (np.array([[[0.0]]], dtype=np.float16), np.float16, NpStrict3DArrayFp16, 3), + (np.array([[[0.0 + 0.0j]]], dtype=np.complex256), np.complex256, NpStrict3DArrayComplexLongDouble, 3), + (np.array([[[0.0 + 0.0j]]]), np.complex128, NpStrict3DArrayComplex128, 3), + (np.array([[[0.0 + 0.0j]]], dtype=np.complex64), np.complex64, NpStrict3DArrayComplex64, 3), + (np.array([[[False]]]), np.bool_, NpStrict3DArrayBool, 3), + (np.array([[[0]]], dtype=np.timedelta64), np.timedelta64, NpStrict3DArrayTimedelta64, 3), +] +strict_data_type_nd_array_typing_dimensions = [ + (np.array([0]), np.int64, NpStrictNDArrayInt64, None), + (np.array([0], dtype=np.int32), np.int32, NpStrictNDArrayInt32, None), + (np.array([0], dtype=np.int16), np.int16, NpStrictNDArrayInt16, None), + (np.array([0], dtype=np.int8), np.int8, NpStrictNDArrayInt8, None), + (np.array([0], dtype=np.uint64), np.uint64, NpStrictNDArrayUint64, None), + (np.array([0], dtype=np.uint32), np.uint32, NpStrictNDArrayUint32, None), + (np.array([0], dtype=np.uint16), np.uint16, NpStrictNDArrayUint16, None), + (np.array([0], dtype=np.uint8), np.uint8, NpStrictNDArrayUint8, None), + (np.array([0.0], dtype=np.float128), np.float128, NpStrictNDArrayFpLongDouble, None), + (np.array([0.0]), np.float64, NpStrictNDArrayFp64, None), + (np.array([0.0], dtype=np.float32), np.float32, NpStrictNDArrayFp32, None), + (np.array([0.0], dtype=np.float16), np.float16, NpStrictNDArrayFp16, None), + (np.array([0.0 + 0.0j], dtype=np.complex256), np.complex256, NpStrictNDArrayComplexLongDouble, None), + (np.array([0.0 + 0.0j]), np.complex128, NpStrictNDArrayComplex128, None), + (np.array([0.0 + 0.0j], dtype=np.complex64), np.complex64, NpStrictNDArrayComplex64, None), + (np.array([False]), np.bool_, NpStrictNDArrayBool, None), + (np.array([0], dtype=np.timedelta64), np.timedelta64, NpStrictNDArrayTimedelta64, None), +] +strict_data_type_array_typing_dimensions = [ + *strict_data_type_1d_array_typing_dimensions, + *strict_data_type_2d_array_typing_dimensions, + *strict_data_type_3d_array_typing_dimensions, + *strict_data_type_nd_array_typing_dimensions, +] + +dimension_testing_group = [ + (np.array([0]), np.int64, Np1DArrayInt64, 1), + (np.array([[0]]), np.int64, Np2DArrayInt64, 2), + (np.array([[[0]]]), np.int64, Np3DArrayInt64, 3), +] diff --git a/tests/test_np_model.py b/tests/test_np_model.py index 6f972f9..66cbfe1 100644 --- a/tests/test_np_model.py +++ b/tests/test_np_model.py @@ -7,7 +7,6 @@ from pydantic_numpy.model import model_agnostic_load from pydantic_numpy.typing import NpNDArray -from tests.helper.cache import cached_hyp_array from tests.model import ( NpNDArrayModelWithNonArray, NpNDArrayModelWithNonArrayWithArbitrary, @@ -18,12 +17,8 @@ NON_ARRAY_VALUE = 5 -def _create_example_array(): - return cached_hyp_array(np.float64, 1).example() - - def _numpy_model(): - return NpNDArrayModelWithNonArray(array=_create_example_array(), non_array=NON_ARRAY_VALUE) + return NpNDArrayModelWithNonArray(array=np.array([0.0]), non_array=NON_ARRAY_VALUE) @pytest.fixture @@ -35,7 +30,7 @@ def numpy_model(): params=[ _numpy_model(), NpNDArrayModelWithNonArrayWithArbitrary( - array=_create_example_array(), non_array=NON_ARRAY_VALUE, my_arbitrary_slice=slice(0, 10) + array=np.array([0.0]), non_array=NON_ARRAY_VALUE, my_arbitrary_slice=slice(0, 10) ), ] ) @@ -73,8 +68,8 @@ class NumpyModelBForTest(NpNDArrayModelWithNonArray): array: NpNDArray non_array: int - model_a = NumpyModelAForTest(array=_create_example_array(), non_array=NON_ARRAY_VALUE) - model_b = NumpyModelBForTest(array=_create_example_array(), non_array=NON_ARRAY_VALUE) + model_a = NumpyModelAForTest(array=np.array([0.0]), non_array=NON_ARRAY_VALUE) + model_b = NumpyModelBForTest(array=np.array([0.0]), non_array=NON_ARRAY_VALUE) with tempfile.TemporaryDirectory() as tmp_dirname: tmp_dir_path = Path(tmp_dirname) @@ -82,6 +77,6 @@ class NumpyModelBForTest(NpNDArrayModelWithNonArray): model_a.dump(tmp_dir_path, TEST_MODEL_OBJECT_ID) model_b.dump(tmp_dir_path, OTHER_TEST_MODEL_OBJECT_ID) - models = [model_a, model_b] + models = [NumpyModelAForTest, NumpyModelBForTest] assert model_a == model_agnostic_load(tmp_dir_path, TEST_MODEL_OBJECT_ID, models=models) assert model_b == model_agnostic_load(tmp_dir_path, OTHER_TEST_MODEL_OBJECT_ID, models=models) diff --git a/tests/test_pydantic.py b/tests/test_pydantic.py index 07790c6..79999d5 100644 --- a/tests/test_pydantic.py +++ b/tests/test_pydantic.py @@ -34,13 +34,13 @@ def test_model_json_schema_np_1d_array_model(self): "properties": { "array": { "properties": { + "data_type": {"default": "Any", "title": "dtype", "type": "string"}, "data": { "items_schema": {"items_schema": {"type": "any"}, "type": "list"}, "max_length": 1, "min_length": 1, "type": "list", }, - "data_type": {"default": "Any", "title": "dtype", "type": "string"}, }, "required": ["data_type", "data"], "title": "Numpy Array", diff --git a/tests/test_typing.py b/tests/test_typing.py index 68babff..72d821b 100644 --- a/tests/test_typing.py +++ b/tests/test_typing.py @@ -1,119 +1,116 @@ import os import tempfile from pathlib import Path -from typing import Hashable, Optional, cast +from typing import Optional import numpy as np +import numpy.typing as npt import orjson import pytest from numpy.testing import assert_almost_equal from pydantic import ValidationError -from pydantic_numpy.helper.typing import SupportedDTypes from pydantic_numpy.helper.validation import PydanticNumpyMultiArrayNumpyFileOnFilePath from pydantic_numpy.model import MultiArrayNumpyFile +from pydantic_numpy.typing import Np1DArrayInt64 from pydantic_numpy.util import np_general_all_close -from tests.helper.cache import cached_calculation, cached_hyp_array -from tests.helper.groups import ( +from tests.helper.cache import get_numpy_type_model +from tests.helper.testing_groups import ( data_type_array_typing_dimensions, data_type_nd_array_typing_dimensions_without_complex, - dimension_testing_group, strict_data_type_nd_array_typing_dimensions, supported_data_types, ) -@pytest.mark.parametrize("numpy_dtype,pydantic_typing,dimensions", data_type_array_typing_dimensions) -def test_correct_type(numpy_dtype: SupportedDTypes, pydantic_typing, dimensions: Optional[int]): - assert cached_calculation(pydantic_typing)( - array_field=cached_hyp_array(cast(Hashable, numpy_dtype), dimensions).example() - ) +@pytest.mark.parametrize("numpy_array, numpy_dtype, pydantic_typing, dimensions", data_type_array_typing_dimensions) +def test_correct_type( + numpy_array: npt.ArrayLike, numpy_dtype: npt.DTypeLike, pydantic_typing, dimensions: Optional[int] +): + assert get_numpy_type_model(pydantic_typing)(array_field=numpy_array) -@pytest.mark.parametrize("numpy_dtype,pydantic_typing,dimensions", strict_data_type_nd_array_typing_dimensions) -@pytest.mark.parametrize("wrong_numpy_type", supported_data_types) -def test_wrong_dtype_type(numpy_dtype: SupportedDTypes, pydantic_typing, dimensions: Optional[int], wrong_numpy_type): +@pytest.mark.parametrize( + "numpy_array, numpy_dtype, pydantic_typing, dimensions", strict_data_type_nd_array_typing_dimensions +) +@pytest.mark.parametrize("bad_numpy_array, wrong_numpy_type", supported_data_types) +def test_wrong_dtype_type( + numpy_array: npt.ArrayLike, + numpy_dtype: npt.DTypeLike, + pydantic_typing, + dimensions: Optional[int], + bad_numpy_array: npt.ArrayLike, + wrong_numpy_type: npt.DTypeLike, +): if wrong_numpy_type == numpy_dtype: return - bad_array = cached_hyp_array(wrong_numpy_type, dimensions).example() with pytest.raises(ValidationError): - cached_calculation(pydantic_typing)(array_field=bad_array) - + get_numpy_type_model(pydantic_typing)(array_field=bad_numpy_array) -@pytest.mark.parametrize("numpy_dtype,pydantic_typing,dimensions", dimension_testing_group) -def test_wrong_dimension(numpy_dtype: SupportedDTypes, pydantic_typing, dimensions: Optional[int]): - assert dimensions is not None - wrong_dimension = dimensions + 1 - bad_array = cached_hyp_array(cast(Hashable, numpy_dtype), wrong_dimension).example() +def test_wrong_dimension(): with pytest.raises(ValueError): - cached_calculation(pydantic_typing)(array_field=bad_array) + get_numpy_type_model(Np1DArrayInt64)(array_field=np.array([[0]])) if os.name != "nt": @pytest.mark.parametrize( - "numpy_dtype,pydantic_typing,dimensions", data_type_nd_array_typing_dimensions_without_complex + "numpy_array, numpy_dtype, pydantic_typing, dimensions", data_type_nd_array_typing_dimensions_without_complex ) - def test_json_serialize_deserialize(numpy_dtype: SupportedDTypes, pydantic_typing, dimensions: Optional[int]): - hyp_array = cached_hyp_array(cast(Hashable, numpy_dtype), dimensions).example() - - numpy_model = cached_calculation(pydantic_typing) - dumped_model_json_loaded = orjson.loads(numpy_model(array_field=hyp_array).model_dump_json()) + def test_json_serialize_deserialize( + numpy_array: npt.ArrayLike, numpy_dtype: npt.DTypeLike, pydantic_typing, dimensions: Optional[int] + ): + numpy_model = get_numpy_type_model(pydantic_typing) + dumped_model_json_loaded = orjson.loads(numpy_model(array_field=numpy_array).model_dump_json()) round_trip_result = numpy_model(array_field=dumped_model_json_loaded["array_field"]).array_field if issubclass(numpy_dtype, np.timedelta64) or issubclass(numpy_dtype, np.datetime64): - assert np.all(hyp_array == round_trip_result) + assert np.all(numpy_array == round_trip_result) else: - assert_almost_equal(hyp_array, round_trip_result) - - @pytest.mark.parametrize("numpy_dtype,pydantic_typing,dimensions", data_type_array_typing_dimensions) - def test_file_path_passing_validation(numpy_dtype: SupportedDTypes, pydantic_typing, dimensions: Optional[int]): - hyp_array = cached_hyp_array(cast(Hashable, numpy_dtype), dimensions).example() + assert_almost_equal(numpy_array, round_trip_result) + @pytest.mark.parametrize("numpy_array, numpy_dtype, pydantic_typing, dimensions", data_type_array_typing_dimensions) + def test_file_path_passing_validation( + numpy_array: npt.ArrayLike, numpy_dtype: npt.DTypeLike, pydantic_typing, dimensions: Optional[int] + ): with tempfile.NamedTemporaryFile(mode="w+", delete=True, suffix=".npz") as tf: - np.savez_compressed(tf.name, my_array=hyp_array) - numpy_model = cached_calculation(pydantic_typing)(array_field=Path(tf.name)) + np.savez_compressed(tf.name, my_array=numpy_array) + numpy_model = get_numpy_type_model(pydantic_typing)(array_field=Path(tf.name)) - assert np_general_all_close(numpy_model.array_field, hyp_array) + assert np_general_all_close(numpy_model.array_field, numpy_array) - @pytest.mark.parametrize("numpy_dtype,pydantic_typing,dimensions", data_type_array_typing_dimensions) + @pytest.mark.parametrize("numpy_array, numpy_dtype, pydantic_typing, dimensions", data_type_array_typing_dimensions) def test_file_path_error_on_reading_single_array_file( - numpy_dtype: SupportedDTypes, pydantic_typing, dimensions: Optional[int] + numpy_array: npt.ArrayLike, numpy_dtype: npt.DTypeLike, pydantic_typing, dimensions: Optional[int] ): - hyp_array = cached_hyp_array(cast(Hashable, numpy_dtype), dimensions).example() - with tempfile.NamedTemporaryFile(mode="w+", delete=True, suffix=".npz") as tf: - np.savez_compressed(tf.name, my_array=hyp_array, my_identical_array=hyp_array) - model = cached_calculation(pydantic_typing) + np.savez_compressed(tf.name, my_array=numpy_array, my_identical_array=numpy_array) + model = get_numpy_type_model(pydantic_typing) with pytest.raises(PydanticNumpyMultiArrayNumpyFileOnFilePath): model(array_field=Path(tf.name)) - @pytest.mark.parametrize("numpy_dtype,pydantic_typing,dimensions", data_type_array_typing_dimensions) + @pytest.mark.parametrize("numpy_array, numpy_dtype, pydantic_typing, dimensions", data_type_array_typing_dimensions) def test_multi_array_numpy_passing_validation( - numpy_dtype: SupportedDTypes, pydantic_typing, dimensions: Optional[int] + numpy_array: npt.ArrayLike, numpy_dtype: npt.DTypeLike, pydantic_typing, dimensions: Optional[int] ): - hyp_array = cached_hyp_array(cast(Hashable, numpy_dtype), dimensions).example() - with tempfile.NamedTemporaryFile(mode="w+", delete=True, suffix=".npz") as tf: - np.savez_compressed(tf.name, my_array=hyp_array) - numpy_model = cached_calculation(pydantic_typing)( + np.savez_compressed(tf.name, my_array=numpy_array) + numpy_model = get_numpy_type_model(pydantic_typing)( array_field=MultiArrayNumpyFile(path=Path(tf.name), key="my_array") ) - assert np_general_all_close(numpy_model.array_field, hyp_array) + assert np_general_all_close(numpy_model.array_field, numpy_array) - @pytest.mark.parametrize("numpy_dtype,pydantic_typing,dimensions", data_type_array_typing_dimensions) + @pytest.mark.parametrize("numpy_array, numpy_dtype, pydantic_typing, dimensions", data_type_array_typing_dimensions) def test_multi_array_numpy_error_on_reading_single_array_file( - numpy_dtype: SupportedDTypes, pydantic_typing, dimensions: Optional[int] + numpy_array: npt.ArrayLike, numpy_dtype: npt.DTypeLike, pydantic_typing, dimensions: Optional[int] ): - hyp_array = cached_hyp_array(cast(Hashable, numpy_dtype), dimensions).example() - with tempfile.NamedTemporaryFile(mode="w+", delete=True, suffix=".npy") as tf: - np.save(tf.name, hyp_array) - model = cached_calculation(pydantic_typing) + np.save(tf.name, numpy_array) + model = get_numpy_type_model(pydantic_typing) with pytest.raises(AttributeError): model(array_field=MultiArrayNumpyFile(path=Path(tf.name), key="my_array"))