From 881f09415a7c2ddd199207a4cb3eee7bf62d667f Mon Sep 17 00:00:00 2001 From: Benyamin Ginzburg Date: Sun, 22 Oct 2023 09:37:46 +0300 Subject: [PATCH] Pydantic v2 --- pdm.lock | 519 ++++++++++++++++++++++++++ pyproject.toml | 14 +- src/example_package/__init__.py | 0 test/test_engine/test_fasts.py | 14 +- test/test_engine/test_holiday.py | 26 +- test/test_engine/test_rosh_chodesh.py | 12 +- test/test_engine/test_shabbat.py | 18 +- test/test_engine/test_yomtov.py | 20 +- test/test_routers/test_main_router.py | 9 +- zmanim_api/api_helpers.py | 7 +- zmanim_api/engine/holidays.py | 5 +- zmanim_api/engine/zmanim_module.py | 6 +- zmanim_api/main.py | 19 +- zmanim_api/models.py | 121 +++--- 14 files changed, 657 insertions(+), 133 deletions(-) create mode 100644 pdm.lock delete mode 100644 src/example_package/__init__.py diff --git a/pdm.lock b/pdm.lock new file mode 100644 index 0000000..457ed19 --- /dev/null +++ b/pdm.lock @@ -0,0 +1,519 @@ +# This file is @generated by PDM. +# It is not intended for manual editing. + +[metadata] +groups = ["default", "test"] +cross_platform = true +static_urls = false +lock_version = "4.3" +content_hash = "sha256:9038636a85335305a8c61bdbab116799071b9a0c3f652c8ef060ac33f5bc3753" + +[[package]] +name = "annotated-types" +version = "0.6.0" +requires_python = ">=3.8" +summary = "Reusable constraint types to use with typing.Annotated" +files = [ + {file = "annotated_types-0.6.0-py3-none-any.whl", hash = "sha256:0641064de18ba7a25dee8f96403ebc39113d0cb953a01429249d5c7564666a43"}, + {file = "annotated_types-0.6.0.tar.gz", hash = "sha256:563339e807e53ffd9c267e99fc6d9ea23eb8443c08f112651963e24e22f84a5d"}, +] + +[[package]] +name = "anyio" +version = "3.7.1" +requires_python = ">=3.7" +summary = "High level compatibility layer for multiple asynchronous event loop implementations" +dependencies = [ + "idna>=2.8", + "sniffio>=1.1", +] +files = [ + {file = "anyio-3.7.1-py3-none-any.whl", hash = "sha256:91dee416e570e92c64041bd18b900d1d6fa78dff7048769ce5ac5ddad004fbb5"}, + {file = "anyio-3.7.1.tar.gz", hash = "sha256:44a3c9aba0f5defa43261a8b3efb97891f2bd7d804e0e1f56419befa1adfc780"}, +] + +[[package]] +name = "arrow" +version = "1.2.3" +requires_python = ">=3.6" +summary = "Better dates & times for Python" +dependencies = [ + "python-dateutil>=2.7.0", +] +files = [ + {file = "arrow-1.2.3-py3-none-any.whl", hash = "sha256:5a49ab92e3b7b71d96cd6bfcc4df14efefc9dfa96ea19045815914a6ab6b1fe2"}, + {file = "arrow-1.2.3.tar.gz", hash = "sha256:3934b30ca1b9f292376d9db15b19446088d12ec58629bc3f0da28fd55fb633a1"}, +] + +[[package]] +name = "betterlogging" +version = "0.2.1" +summary = "My logging improvement" +files = [ + {file = "betterlogging-0.2.1-py3-none-any.whl", hash = "sha256:fc289ac94bf13b44286438d73edd0563f2259b681364f34eeeaff970fada46dd"}, + {file = "betterlogging-0.2.1.tar.gz", hash = "sha256:e2bc423ba0e06c94dc90f5db06d2d8b656807e33fecd02c43af7175236849d34"}, +] + +[[package]] +name = "certifi" +version = "2023.7.22" +requires_python = ">=3.6" +summary = "Python package for providing Mozilla's CA Bundle." +files = [ + {file = "certifi-2023.7.22-py3-none-any.whl", hash = "sha256:92d6037539857d8206b8f6ae472e8b77db8058fec5937a1ef3f54304089edbb9"}, + {file = "certifi-2023.7.22.tar.gz", hash = "sha256:539cc1d13202e33ca466e88b2807e29f4c13049d6d87031a3c110744495cb082"}, +] + +[[package]] +name = "cffi" +version = "1.16.0" +requires_python = ">=3.8" +summary = "Foreign Function Interface for Python calling C code." +dependencies = [ + "pycparser", +] +files = [ + {file = "cffi-1.16.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:b84834d0cf97e7d27dd5b7f3aca7b6e9263c56308ab9dc8aae9784abb774d404"}, + {file = "cffi-1.16.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:1b8ebc27c014c59692bb2664c7d13ce7a6e9a629be20e54e7271fa696ff2b417"}, + {file = "cffi-1.16.0-cp311-cp311-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:ee07e47c12890ef248766a6e55bd38ebfb2bb8edd4142d56db91b21ea68b7627"}, + {file = "cffi-1.16.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d8a9d3ebe49f084ad71f9269834ceccbf398253c9fac910c4fd7053ff1386936"}, + {file = "cffi-1.16.0-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:e70f54f1796669ef691ca07d046cd81a29cb4deb1e5f942003f401c0c4a2695d"}, + {file = "cffi-1.16.0-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:5bf44d66cdf9e893637896c7faa22298baebcd18d1ddb6d2626a6e39793a1d56"}, + {file = "cffi-1.16.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:7b78010e7b97fef4bee1e896df8a4bbb6712b7f05b7ef630f9d1da00f6444d2e"}, + {file = "cffi-1.16.0-cp311-cp311-musllinux_1_1_i686.whl", hash = "sha256:c6a164aa47843fb1b01e941d385aab7215563bb8816d80ff3a363a9f8448a8dc"}, + {file = "cffi-1.16.0-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:e09f3ff613345df5e8c3667da1d918f9149bd623cd9070c983c013792a9a62eb"}, + {file = "cffi-1.16.0-cp311-cp311-win32.whl", hash = "sha256:2c56b361916f390cd758a57f2e16233eb4f64bcbeee88a4881ea90fca14dc6ab"}, + {file = "cffi-1.16.0-cp311-cp311-win_amd64.whl", hash = "sha256:db8e577c19c0fda0beb7e0d4e09e0ba74b1e4c092e0e40bfa12fe05b6f6d75ba"}, + {file = "cffi-1.16.0.tar.gz", hash = "sha256:bcb3ef43e58665bbda2fb198698fcae6776483e0c4a631aa5647806c25e02cc0"}, +] + +[[package]] +name = "click" +version = "8.1.7" +requires_python = ">=3.7" +summary = "Composable command line interface toolkit" +dependencies = [ + "colorama; platform_system == \"Windows\"", +] +files = [ + {file = "click-8.1.7-py3-none-any.whl", hash = "sha256:ae74fb96c20a0277a1d615f1e4d73c8414f5a98db8b799a7931d1582f3390c28"}, + {file = "click-8.1.7.tar.gz", hash = "sha256:ca9853ad459e787e2192211578cc907e7594e294c7ccc834310722b41b9ca6de"}, +] + +[[package]] +name = "colorama" +version = "0.4.6" +requires_python = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,>=2.7" +summary = "Cross-platform colored terminal text." +files = [ + {file = "colorama-0.4.6-py2.py3-none-any.whl", hash = "sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6"}, + {file = "colorama-0.4.6.tar.gz", hash = "sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44"}, +] + +[[package]] +name = "coverage" +version = "7.2.3" +requires_python = ">=3.7" +summary = "Code coverage measurement for Python" +files = [ + {file = "coverage-7.2.3-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:dfd393094cd82ceb9b40df4c77976015a314b267d498268a076e940fe7be6b79"}, + {file = "coverage-7.2.3-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:182eb9ac3f2b4874a1f41b78b87db20b66da6b9cdc32737fbbf4fea0c35b23fc"}, + {file = "coverage-7.2.3-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:1bb1e77a9a311346294621be905ea8a2c30d3ad371fc15bb72e98bfcfae532df"}, + {file = "coverage-7.2.3-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:ca0f34363e2634deffd390a0fef1aa99168ae9ed2af01af4a1f5865e362f8623"}, + {file = "coverage-7.2.3-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:55416d7385774285b6e2a5feca0af9652f7f444a4fa3d29d8ab052fafef9d00d"}, + {file = "coverage-7.2.3-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:06ddd9c0249a0546997fdda5a30fbcb40f23926df0a874a60a8a185bc3a87d93"}, + {file = "coverage-7.2.3-cp311-cp311-musllinux_1_1_i686.whl", hash = "sha256:fff5aaa6becf2c6a1699ae6a39e2e6fb0672c2d42eca8eb0cafa91cf2e9bd312"}, + {file = "coverage-7.2.3-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:ea53151d87c52e98133eb8ac78f1206498c015849662ca8dc246255265d9c3c4"}, + {file = "coverage-7.2.3-cp311-cp311-win32.whl", hash = "sha256:8f6c930fd70d91ddee53194e93029e3ef2aabe26725aa3c2753df057e296b925"}, + {file = "coverage-7.2.3-cp311-cp311-win_amd64.whl", hash = "sha256:fa546d66639d69aa967bf08156eb8c9d0cd6f6de84be9e8c9819f52ad499c910"}, + {file = "coverage-7.2.3-pp37.pp38.pp39-none-any.whl", hash = "sha256:965ee3e782c7892befc25575fa171b521d33798132692df428a09efacaffe8d0"}, + {file = "coverage-7.2.3.tar.gz", hash = "sha256:d298c2815fa4891edd9abe5ad6e6cb4207104c7dd9fd13aea3fdebf6f9b91259"}, +] + +[[package]] +name = "fastapi" +version = "0.104.0" +requires_python = ">=3.8" +summary = "FastAPI framework, high performance, easy to learn, fast to code, ready for production" +dependencies = [ + "anyio<4.0.0,>=3.7.1", + "pydantic!=1.8,!=1.8.1,!=2.0.0,!=2.0.1,!=2.1.0,<3.0.0,>=1.7.4", + "starlette<0.28.0,>=0.27.0", + "typing-extensions>=4.8.0", +] +files = [ + {file = "fastapi-0.104.0-py3-none-any.whl", hash = "sha256:456482c1178fb7beb2814b88e1885bc49f9a81f079665016feffe3e1c6a7663e"}, + {file = "fastapi-0.104.0.tar.gz", hash = "sha256:9c44de45693ae037b0c6914727a29c49a40668432b67c859a87851fc6a7b74c6"}, +] + +[[package]] +name = "h11" +version = "0.14.0" +requires_python = ">=3.7" +summary = "A pure-Python, bring-your-own-I/O implementation of HTTP/1.1" +files = [ + {file = "h11-0.14.0-py3-none-any.whl", hash = "sha256:e3fe4ac4b851c468cc8363d500db52c2ead036020723024a109d37346efaa761"}, + {file = "h11-0.14.0.tar.gz", hash = "sha256:8f19fbbe99e72420ff35c00b27a34cb9937e902a8b810e2c88300c6f0a3b699d"}, +] + +[[package]] +name = "h3" +version = "3.7.6" +summary = "Hierarchical hexagonal geospatial indexing system" +files = [ + {file = "h3-3.7.6-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:991ee991f2ae41f629feb1cd32fa677b8512c72696eb0ad94fcf359d61184b2e"}, + {file = "h3-3.7.6-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:fcbfff87d223279f8e38bbee3ebf52b1b96ae280e9e7de24674d3c284373d946"}, + {file = "h3-3.7.6-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:eddf10d1d2139b3ea3ad1618c2074e1c47d3d36bddb5359e4955f5fd0b089d93"}, + {file = "h3-3.7.6-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:76abc02f14a8df42fb5d80e6045023fb756c49d3cb08d69a8ceb9362b95d4bec"}, + {file = "h3-3.7.6-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:fc8030968586a7810aa192397ad9a4f7d7a963f57c9b3e210fc38de0aa5c2533"}, + {file = "h3-3.7.6-cp311-cp311-win_amd64.whl", hash = "sha256:1bdc790d91138e781973dcaade5231db7fe8a876330939e0903f602acc4fb64c"}, + {file = "h3-3.7.6.tar.gz", hash = "sha256:9bbd3dbac99532fa521d7d2e288ff55877bea3223b070f659ed7b5f8f1f213eb"}, +] + +[[package]] +name = "httpcore" +version = "0.18.0" +requires_python = ">=3.8" +summary = "A minimal low-level HTTP client." +dependencies = [ + "anyio<5.0,>=3.0", + "certifi", + "h11<0.15,>=0.13", + "sniffio==1.*", +] +files = [ + {file = "httpcore-0.18.0-py3-none-any.whl", hash = "sha256:adc5398ee0a476567bf87467063ee63584a8bce86078bf748e48754f60202ced"}, + {file = "httpcore-0.18.0.tar.gz", hash = "sha256:13b5e5cd1dca1a6636a6aaea212b19f4f85cd88c366a2b82304181b769aab3c9"}, +] + +[[package]] +name = "httpx" +version = "0.25.0" +requires_python = ">=3.8" +summary = "The next generation HTTP client." +dependencies = [ + "certifi", + "httpcore<0.19.0,>=0.18.0", + "idna", + "sniffio", +] +files = [ + {file = "httpx-0.25.0-py3-none-any.whl", hash = "sha256:181ea7f8ba3a82578be86ef4171554dd45fec26a02556a744db029a0a27b7100"}, + {file = "httpx-0.25.0.tar.gz", hash = "sha256:47ecda285389cb32bb2691cc6e069e3ab0205956f681c5b2ad2325719751d875"}, +] + +[[package]] +name = "idna" +version = "3.4" +requires_python = ">=3.5" +summary = "Internationalized Domain Names in Applications (IDNA)" +files = [ + {file = "idna-3.4-py3-none-any.whl", hash = "sha256:90b77e79eaa3eba6de819a0c442c0b4ceefc341a7a2ab77d7562bf49f425c5c2"}, + {file = "idna-3.4.tar.gz", hash = "sha256:814f528e8dead7d329833b91c5faa87d60bf71824cd12a7530b5526063d02cb4"}, +] + +[[package]] +name = "iniconfig" +version = "2.0.0" +requires_python = ">=3.7" +summary = "brain-dead simple config-ini parsing" +files = [ + {file = "iniconfig-2.0.0-py3-none-any.whl", hash = "sha256:b6a85871a79d2e3b22d2d1b94ac2824226a63c6b741c88f7ae975f18b6778374"}, + {file = "iniconfig-2.0.0.tar.gz", hash = "sha256:2d91e135bf72d31a410b17c16da610a82cb55f6b0477d1a902134b24a455b8b3"}, +] + +[[package]] +name = "julian" +version = "0.14" +summary = "Simple library for converting between Julian calendar dates and datetime objects" +files = [ + {file = "julian-0.14.zip", hash = "sha256:deee4090faad584c1875d97e72808198f802a9d2dc38a70fe2a8f790ea5dbd0a"}, +] + +[[package]] +name = "memoization" +version = "0.4.0" +requires_python = ">=3, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, <4" +summary = "A powerful caching library for Python, with TTL support and multiple algorithm options. (https://github.com/lonelyenvoy/python-memoization)" +files = [ + {file = "memoization-0.4.0.tar.gz", hash = "sha256:fde5e7cd060ef45b135e0310cfec17b2029dc472ccb5bbbbb42a503d4538a135"}, +] + +[[package]] +name = "numpy" +version = "1.26.1" +requires_python = "<3.13,>=3.9" +summary = "Fundamental package for array computing in Python" +files = [ + {file = "numpy-1.26.1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:cd7837b2b734ca72959a1caf3309457a318c934abef7a43a14bb984e574bbb9a"}, + {file = "numpy-1.26.1-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:1c59c046c31a43310ad0199d6299e59f57a289e22f0f36951ced1c9eac3665b9"}, + {file = "numpy-1.26.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d58e8c51a7cf43090d124d5073bc29ab2755822181fcad978b12e144e5e5a4b3"}, + {file = "numpy-1.26.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6081aed64714a18c72b168a9276095ef9155dd7888b9e74b5987808f0dd0a974"}, + {file = "numpy-1.26.1-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:97e5d6a9f0702c2863aaabf19f0d1b6c2628fbe476438ce0b5ce06e83085064c"}, + {file = "numpy-1.26.1-cp311-cp311-win32.whl", hash = "sha256:b9d45d1dbb9de84894cc50efece5b09939752a2d75aab3a8b0cef6f3a35ecd6b"}, + {file = "numpy-1.26.1-cp311-cp311-win_amd64.whl", hash = "sha256:3649d566e2fc067597125428db15d60eb42a4e0897fc48d28cb75dc2e0454e53"}, + {file = "numpy-1.26.1-pp39-pypy39_pp73-macosx_10_9_x86_64.whl", hash = "sha256:06934e1a22c54636a059215d6da99e23286424f316fddd979f5071093b648668"}, + {file = "numpy-1.26.1-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:76ff661a867d9272cd2a99eed002470f46dbe0943a5ffd140f49be84f68ffc42"}, + {file = "numpy-1.26.1-pp39-pypy39_pp73-win_amd64.whl", hash = "sha256:6965888d65d2848e8768824ca8288db0a81263c1efccec881cb35a0d805fcd2f"}, + {file = "numpy-1.26.1.tar.gz", hash = "sha256:c8c6c72d4a9f831f328efb1312642a1cafafaa88981d9ab76368d50d07d93cbe"}, +] + +[[package]] +name = "packaging" +version = "23.2" +requires_python = ">=3.7" +summary = "Core utilities for Python packages" +files = [ + {file = "packaging-23.2-py3-none-any.whl", hash = "sha256:8c491190033a9af7e1d931d0b5dacc2ef47509b34dd0de67ed209b5203fc88c7"}, + {file = "packaging-23.2.tar.gz", hash = "sha256:048fb0e9405036518eaaf48a55953c750c11e1a1b68e0dd1a9d62ed0c092cfc5"}, +] + +[[package]] +name = "pluggy" +version = "1.3.0" +requires_python = ">=3.8" +summary = "plugin and hook calling mechanisms for python" +files = [ + {file = "pluggy-1.3.0-py3-none-any.whl", hash = "sha256:d89c696a773f8bd377d18e5ecda92b7a3793cbe66c87060a6fb58c7b6e1061f7"}, + {file = "pluggy-1.3.0.tar.gz", hash = "sha256:cf61ae8f126ac6f7c451172cf30e3e43d3ca77615509771b3a984a0730651e12"}, +] + +[[package]] +name = "pycparser" +version = "2.21" +requires_python = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" +summary = "C parser in Python" +files = [ + {file = "pycparser-2.21-py2.py3-none-any.whl", hash = "sha256:8ee45429555515e1f6b185e78100aea234072576aa43ab53aefcae078162fca9"}, + {file = "pycparser-2.21.tar.gz", hash = "sha256:e644fdec12f7872f86c58ff790da456218b10f863970249516d60a5eaca77206"}, +] + +[[package]] +name = "pydantic" +version = "2.4.2" +requires_python = ">=3.7" +summary = "Data validation using Python type hints" +dependencies = [ + "annotated-types>=0.4.0", + "pydantic-core==2.10.1", + "typing-extensions>=4.6.1", +] +files = [ + {file = "pydantic-2.4.2-py3-none-any.whl", hash = "sha256:bc3ddf669d234f4220e6e1c4d96b061abe0998185a8d7855c0126782b7abc8c1"}, + {file = "pydantic-2.4.2.tar.gz", hash = "sha256:94f336138093a5d7f426aac732dcfe7ab4eb4da243c88f891d65deb4a2556ee7"}, +] + +[[package]] +name = "pydantic-core" +version = "2.10.1" +requires_python = ">=3.7" +summary = "" +dependencies = [ + "typing-extensions!=4.7.0,>=4.6.0", +] +files = [ + {file = "pydantic_core-2.10.1-cp311-cp311-macosx_10_7_x86_64.whl", hash = "sha256:073d4a470b195d2b2245d0343569aac7e979d3a0dcce6c7d2af6d8a920ad0bea"}, + {file = "pydantic_core-2.10.1-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:600d04a7b342363058b9190d4e929a8e2e715c5682a70cc37d5ded1e0dd370b4"}, + {file = "pydantic_core-2.10.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:39215d809470f4c8d1881758575b2abfb80174a9e8daf8f33b1d4379357e417c"}, + {file = "pydantic_core-2.10.1-cp311-cp311-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:eeb3d3d6b399ffe55f9a04e09e635554012f1980696d6b0aca3e6cf42a17a03b"}, + {file = "pydantic_core-2.10.1-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:a7a7902bf75779bc12ccfc508bfb7a4c47063f748ea3de87135d433a4cca7a2f"}, + {file = "pydantic_core-2.10.1-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:3625578b6010c65964d177626fde80cf60d7f2e297d56b925cb5cdeda6e9925a"}, + {file = "pydantic_core-2.10.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:caa48fc31fc7243e50188197b5f0c4228956f97b954f76da157aae7f67269ae8"}, + {file = "pydantic_core-2.10.1-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:07ec6d7d929ae9c68f716195ce15e745b3e8fa122fc67698ac6498d802ed0fa4"}, + {file = "pydantic_core-2.10.1-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:e6f31a17acede6a8cd1ae2d123ce04d8cca74056c9d456075f4f6f85de055607"}, + {file = "pydantic_core-2.10.1-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:d8f1ebca515a03e5654f88411420fea6380fc841d1bea08effb28184e3d4899f"}, + {file = "pydantic_core-2.10.1-cp311-none-win32.whl", hash = "sha256:6db2eb9654a85ada248afa5a6db5ff1cf0f7b16043a6b070adc4a5be68c716d6"}, + {file = "pydantic_core-2.10.1-cp311-none-win_amd64.whl", hash = "sha256:4a5be350f922430997f240d25f8219f93b0c81e15f7b30b868b2fddfc2d05f27"}, + {file = "pydantic_core-2.10.1-cp311-none-win_arm64.whl", hash = "sha256:5fdb39f67c779b183b0c853cd6b45f7db84b84e0571b3ef1c89cdb1dfc367325"}, + {file = "pydantic_core-2.10.1-pp310-pypy310_pp73-macosx_10_7_x86_64.whl", hash = "sha256:d43002441932f9a9ea5d6f9efaa2e21458221a3a4b417a14027a1d530201ef1b"}, + {file = "pydantic_core-2.10.1-pp310-pypy310_pp73-macosx_11_0_arm64.whl", hash = "sha256:fcb83175cc4936a5425dde3356f079ae03c0802bbdf8ff82c035f8a54b333521"}, + {file = "pydantic_core-2.10.1-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:962ed72424bf1f72334e2f1e61b68f16c0e596f024ca7ac5daf229f7c26e4208"}, + {file = "pydantic_core-2.10.1-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:2cf5bb4dd67f20f3bbc1209ef572a259027c49e5ff694fa56bed62959b41e1f9"}, + {file = "pydantic_core-2.10.1-pp310-pypy310_pp73-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:e544246b859f17373bed915182ab841b80849ed9cf23f1f07b73b7c58baee5fb"}, + {file = "pydantic_core-2.10.1-pp310-pypy310_pp73-musllinux_1_1_aarch64.whl", hash = "sha256:c0877239307b7e69d025b73774e88e86ce82f6ba6adf98f41069d5b0b78bd1bf"}, + {file = "pydantic_core-2.10.1-pp310-pypy310_pp73-musllinux_1_1_x86_64.whl", hash = "sha256:53df009d1e1ba40f696f8995683e067e3967101d4bb4ea6f667931b7d4a01357"}, + {file = "pydantic_core-2.10.1-pp310-pypy310_pp73-win_amd64.whl", hash = "sha256:a1254357f7e4c82e77c348dabf2d55f1d14d19d91ff025004775e70a6ef40ada"}, + {file = "pydantic_core-2.10.1-pp37-pypy37_pp73-macosx_10_7_x86_64.whl", hash = "sha256:524ff0ca3baea164d6d93a32c58ac79eca9f6cf713586fdc0adb66a8cdeab96a"}, + {file = "pydantic_core-2.10.1-pp37-pypy37_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:3f0ac9fb8608dbc6eaf17956bf623c9119b4db7dbb511650910a82e261e6600f"}, + {file = "pydantic_core-2.10.1-pp37-pypy37_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:320f14bd4542a04ab23747ff2c8a778bde727158b606e2661349557f0770711e"}, + {file = "pydantic_core-2.10.1-pp37-pypy37_pp73-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:63974d168b6233b4ed6a0046296803cb13c56637a7b8106564ab575926572a55"}, + {file = "pydantic_core-2.10.1-pp37-pypy37_pp73-musllinux_1_1_aarch64.whl", hash = "sha256:417243bf599ba1f1fef2bb8c543ceb918676954734e2dcb82bf162ae9d7bd514"}, + {file = "pydantic_core-2.10.1-pp37-pypy37_pp73-musllinux_1_1_x86_64.whl", hash = "sha256:dda81e5ec82485155a19d9624cfcca9be88a405e2857354e5b089c2a982144b2"}, + {file = "pydantic_core-2.10.1-pp37-pypy37_pp73-win_amd64.whl", hash = "sha256:14cfbb00959259e15d684505263d5a21732b31248a5dd4941f73a3be233865b9"}, + {file = "pydantic_core-2.10.1-pp38-pypy38_pp73-macosx_10_7_x86_64.whl", hash = "sha256:631cb7415225954fdcc2a024119101946793e5923f6c4d73a5914d27eb3d3a05"}, + {file = "pydantic_core-2.10.1-pp38-pypy38_pp73-macosx_11_0_arm64.whl", hash = "sha256:bec7dd208a4182e99c5b6c501ce0b1f49de2802448d4056091f8e630b28e9a52"}, + {file = "pydantic_core-2.10.1-pp38-pypy38_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:149b8a07712f45b332faee1a2258d8ef1fb4a36f88c0c17cb687f205c5dc6e7d"}, + {file = "pydantic_core-2.10.1-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:4d966c47f9dd73c2d32a809d2be529112d509321c5310ebf54076812e6ecd884"}, + {file = "pydantic_core-2.10.1-pp38-pypy38_pp73-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:7eb037106f5c6b3b0b864ad226b0b7ab58157124161d48e4b30c4a43fef8bc4b"}, + {file = "pydantic_core-2.10.1-pp38-pypy38_pp73-musllinux_1_1_aarch64.whl", hash = "sha256:154ea7c52e32dce13065dbb20a4a6f0cc012b4f667ac90d648d36b12007fa9f7"}, + {file = "pydantic_core-2.10.1-pp38-pypy38_pp73-musllinux_1_1_x86_64.whl", hash = "sha256:e562617a45b5a9da5be4abe72b971d4f00bf8555eb29bb91ec2ef2be348cd132"}, + {file = "pydantic_core-2.10.1-pp38-pypy38_pp73-win_amd64.whl", hash = "sha256:f23b55eb5464468f9e0e9a9935ce3ed2a870608d5f534025cd5536bca25b1402"}, + {file = "pydantic_core-2.10.1-pp39-pypy39_pp73-macosx_10_7_x86_64.whl", hash = "sha256:e9121b4009339b0f751955baf4543a0bfd6bc3f8188f8056b1a25a2d45099934"}, + {file = "pydantic_core-2.10.1-pp39-pypy39_pp73-macosx_11_0_arm64.whl", hash = "sha256:0523aeb76e03f753b58be33b26540880bac5aa54422e4462404c432230543f33"}, + {file = "pydantic_core-2.10.1-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:2e0e2959ef5d5b8dc9ef21e1a305a21a36e254e6a34432d00c72a92fdc5ecda5"}, + {file = "pydantic_core-2.10.1-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:da01bec0a26befab4898ed83b362993c844b9a607a86add78604186297eb047e"}, + {file = "pydantic_core-2.10.1-pp39-pypy39_pp73-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:f2e9072d71c1f6cfc79a36d4484c82823c560e6f5599c43c1ca6b5cdbd54f881"}, + {file = "pydantic_core-2.10.1-pp39-pypy39_pp73-musllinux_1_1_aarch64.whl", hash = "sha256:f36a3489d9e28fe4b67be9992a23029c3cec0babc3bd9afb39f49844a8c721c5"}, + {file = "pydantic_core-2.10.1-pp39-pypy39_pp73-musllinux_1_1_x86_64.whl", hash = "sha256:f64f82cc3443149292b32387086d02a6c7fb39b8781563e0ca7b8d7d9cf72bd7"}, + {file = "pydantic_core-2.10.1-pp39-pypy39_pp73-win_amd64.whl", hash = "sha256:b4a6db486ac8e99ae696e09efc8b2b9fea67b63c8f88ba7a1a16c24a057a0776"}, + {file = "pydantic_core-2.10.1.tar.gz", hash = "sha256:0f8682dbdd2f67f8e1edddcbffcc29f60a6182b4901c367fc8c1c40d30bb0a82"}, +] + +[[package]] +name = "pytest" +version = "7.4.2" +requires_python = ">=3.7" +summary = "pytest: simple powerful testing with Python" +dependencies = [ + "colorama; sys_platform == \"win32\"", + "iniconfig", + "packaging", + "pluggy<2.0,>=0.12", +] +files = [ + {file = "pytest-7.4.2-py3-none-any.whl", hash = "sha256:1d881c6124e08ff0a1bb75ba3ec0bfd8b5354a01c194ddd5a0a870a48d99b002"}, + {file = "pytest-7.4.2.tar.gz", hash = "sha256:a766259cfab564a2ad52cb1aae1b881a75c3eb7e34ca3779697c23ed47c47069"}, +] + +[[package]] +name = "python-dateutil" +version = "2.8.2" +requires_python = "!=3.0.*,!=3.1.*,!=3.2.*,>=2.7" +summary = "Extensions to the standard Python datetime module" +dependencies = [ + "six>=1.5", +] +files = [ + {file = "python-dateutil-2.8.2.tar.gz", hash = "sha256:0123cacc1627ae19ddf3c27a5de5bd67ee4586fbdd6440d9748f8abb483d3e86"}, + {file = "python_dateutil-2.8.2-py2.py3-none-any.whl", hash = "sha256:961d03dc3453ebbc59dbdea9e4e11c5651520a876d0f4db161e8674aae935da9"}, +] + +[[package]] +name = "sentry-sdk" +version = "1.32.0" +summary = "Python client for Sentry (https://sentry.io)" +dependencies = [ + "certifi", + "urllib3>=1.26.11; python_version >= \"3.6\"", +] +files = [ + {file = "sentry-sdk-1.32.0.tar.gz", hash = "sha256:935e8fbd7787a3702457393b74b13d89a5afb67185bc0af85c00cb27cbd42e7c"}, + {file = "sentry_sdk-1.32.0-py2.py3-none-any.whl", hash = "sha256:eeb0b3550536f3bbc05bb1c7e0feb3a78d74acb43b607159a606ed2ec0a33a4d"}, +] + +[[package]] +name = "setuptools" +version = "68.2.2" +requires_python = ">=3.8" +summary = "Easily download, build, install, upgrade, and uninstall Python packages" +files = [ + {file = "setuptools-68.2.2-py3-none-any.whl", hash = "sha256:b454a35605876da60632df1a60f736524eb73cc47bbc9f3f1ef1b644de74fd2a"}, + {file = "setuptools-68.2.2.tar.gz", hash = "sha256:4ac1475276d2f1c48684874089fefcd83bd7162ddaafb81fac866ba0db282a87"}, +] + +[[package]] +name = "six" +version = "1.16.0" +requires_python = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*" +summary = "Python 2 and 3 compatibility utilities" +files = [ + {file = "six-1.16.0-py2.py3-none-any.whl", hash = "sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254"}, + {file = "six-1.16.0.tar.gz", hash = "sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926"}, +] + +[[package]] +name = "sniffio" +version = "1.3.0" +requires_python = ">=3.7" +summary = "Sniff out which async library your code is running under" +files = [ + {file = "sniffio-1.3.0-py3-none-any.whl", hash = "sha256:eecefdce1e5bbfb7ad2eeaabf7c1eeb404d7757c379bd1f7e5cce9d8bf425384"}, + {file = "sniffio-1.3.0.tar.gz", hash = "sha256:e60305c5e5d314f5389259b7f22aaa33d8f7dee49763119234af3755c55b9101"}, +] + +[[package]] +name = "starlette" +version = "0.27.0" +requires_python = ">=3.7" +summary = "The little ASGI library that shines." +dependencies = [ + "anyio<5,>=3.4.0", +] +files = [ + {file = "starlette-0.27.0-py3-none-any.whl", hash = "sha256:918416370e846586541235ccd38a474c08b80443ed31c578a418e2209b3eef91"}, + {file = "starlette-0.27.0.tar.gz", hash = "sha256:6a6b0d042acb8d469a01eba54e9cda6cbd24ac602c4cd016723117d6a7e73b75"}, +] + +[[package]] +name = "timezonefinder" +version = "6.2.0" +requires_python = ">=3.8,<4" +summary = "fast python package for finding the timezone of any point on earth (coordinates) offline" +dependencies = [ + "cffi<2,>=1.15.1", + "h3<4,>=3.7.6", + "numpy<2,>=1.18", + "setuptools>=65.5", +] +files = [ + {file = "timezonefinder-6.2.0.tar.gz", hash = "sha256:d41fd2650bb4221fae5a61f9c2767158f9727c4aaca95e24da86394feb704220"}, +] + +[[package]] +name = "typing-extensions" +version = "4.8.0" +requires_python = ">=3.8" +summary = "Backported and Experimental Type Hints for Python 3.8+" +files = [ + {file = "typing_extensions-4.8.0-py3-none-any.whl", hash = "sha256:8f92fc8806f9a6b641eaa5318da32b44d401efaac0f6678c9bc448ba3605faa0"}, + {file = "typing_extensions-4.8.0.tar.gz", hash = "sha256:df8e4339e9cb77357558cbdbceca33c303714cf861d1eef15e1070055ae8b7ef"}, +] + +[[package]] +name = "tzdata" +version = "2023.3" +requires_python = ">=2" +summary = "Provider of IANA time zone data" +files = [ + {file = "tzdata-2023.3-py2.py3-none-any.whl", hash = "sha256:7e65763eef3120314099b6939b5546db7adce1e7d6f2e179e3df563c70511eda"}, + {file = "tzdata-2023.3.tar.gz", hash = "sha256:11ef1e08e54acb0d4f95bdb1be05da659673de4acbd21bf9c69e94cc5e907a3a"}, +] + +[[package]] +name = "urllib3" +version = "2.0.7" +requires_python = ">=3.7" +summary = "HTTP library with thread-safe connection pooling, file post, and more." +files = [ + {file = "urllib3-2.0.7-py3-none-any.whl", hash = "sha256:fdb6d215c776278489906c2f8916e6e7d4f5a9b602ccbcfdf7f016fc8da0596e"}, + {file = "urllib3-2.0.7.tar.gz", hash = "sha256:c97dfde1f7bd43a71c8d2a58e369e9b2bf692d1334ea9f9cae55add7d0dd0f84"}, +] + +[[package]] +name = "uvicorn" +version = "0.23.2" +requires_python = ">=3.8" +summary = "The lightning-fast ASGI server." +dependencies = [ + "click>=7.0", + "h11>=0.8", +] +files = [ + {file = "uvicorn-0.23.2-py3-none-any.whl", hash = "sha256:1f9be6558f01239d4fdf22ef8126c39cb1ad0addf76c40e760549d2c2f43ab53"}, + {file = "uvicorn-0.23.2.tar.gz", hash = "sha256:4d3cc12d7727ba72b64d12d3cc7743124074c0a69f7b201512fc50c3e3f1569a"}, +] + +[[package]] +name = "zmanim" +version = "0.3.1" +requires_python = ">=3.6" +summary = "A Zmanim library for Python" +dependencies = [ + "julian", + "memoization", + "python-dateutil", +] +files = [ + {file = "zmanim-0.3.1-py3-none-any.whl", hash = "sha256:ae3cf6d8878d7a50ed6beb76c6da7abca5063b02f70e781519d705b5cc317d79"}, + {file = "zmanim-0.3.1.tar.gz", hash = "sha256:10883ae3f0903175d5f038ef5a12fba37bec71e0ea1713712720c77b3926d2b0"}, +] diff --git a/pyproject.toml b/pyproject.toml index 3b2c958..ea665f0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,15 +8,15 @@ authors = [ {name = "Benyamin Ginzburg", email = "benyomin.94@gmail.com"}, ] dependencies = [ - "fastapi==0.95.0", - "pydantic==1.10.7", - "uvicorn==0.21.1", - "pytz==2023.3", + "fastapi==0.104.0", + "pydantic==2.4.2", + "uvicorn==0.23.2", "arrow==1.2.3", "timezonefinder==6.2.0", "zmanim==0.3.1", "betterlogging==0.2.1", - "sentry-sdk==1.19.1", + "sentry-sdk==1.32.0", + "tzdata" ] requires-python = ">=3.11,<3.12" readme = "README.md" @@ -25,8 +25,8 @@ license = {text = "GPL-3.0"} [tool.pdm.dev-dependencies] test = [ - "pytest==7.3.0", - "httpx==0.24.0", + "pytest==7.4.2", + "httpx==0.25.0", "coverage==7.2.3", ] diff --git a/src/example_package/__init__.py b/src/example_package/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/test/test_engine/test_fasts.py b/test/test_engine/test_fasts.py index 4a8d34f..f6a78d9 100644 --- a/test/test_engine/test_fasts.py +++ b/test/test_engine/test_fasts.py @@ -28,7 +28,7 @@ def test_regular_fast(): LNG, ZERO_ELEVATION ) - assert actual.dict(exclude_none=True, by_alias=True) == expected + assert actual.model_dump(exclude_none=True, by_alias=True) == expected def test_moved_fast_esther(): @@ -53,7 +53,7 @@ def test_moved_fast_esther(): LNG, ZERO_ELEVATION ) - assert actual.dict(exclude_none=True, by_alias=True) == expected + assert actual.model_dump(exclude_none=True, by_alias=True) == expected def test_moved_fast_tammuz_and_av(): @@ -100,8 +100,8 @@ def test_moved_fast_tammuz_and_av(): ZERO_ELEVATION, ) - assert actual_1.dict(exclude_none=True, by_alias=True) == expected_1 - assert actual_2.dict(exclude_none=True, by_alias=True) == expected_2 + assert actual_1.model_dump(exclude_none=True, by_alias=True) == expected_1 + assert actual_2.model_dump(exclude_none=True, by_alias=True) == expected_2 def test_day_after_moved_fast_tammuz_and_av(): @@ -147,8 +147,8 @@ def test_day_after_moved_fast_tammuz_and_av(): ZERO_ELEVATION, ) - assert actual_1.dict(exclude_none=True, by_alias=True) == expected_1 - assert actual_2.dict(exclude_none=True, by_alias=True) == expected_2 + assert actual_1.model_dump(exclude_none=True, by_alias=True) == expected_1 + assert actual_2.model_dump(exclude_none=True, by_alias=True) == expected_2 def test_9_of_av_in_north(): @@ -170,5 +170,5 @@ def test_9_of_av_in_north(): 63.44563381372263, 13.49966869597185, ZERO_ELEVATION, - ).dict(exclude_none=True, by_alias=True) + ).model_dump(exclude_none=True, by_alias=True) assert actual == expected diff --git a/test/test_engine/test_holiday.py b/test/test_engine/test_holiday.py index 389d1e5..cdc0cca 100644 --- a/test/test_engine/test_holiday.py +++ b/test/test_engine/test_holiday.py @@ -15,7 +15,7 @@ def test_regular_holiday(): } actual = get_simple_holiday(SimpleHolidayChoices.tu_bi_shvat.value, PY_DATE) - assert actual.dict(exclude_none=True, by_alias=True) == expected + assert actual.model_dump(exclude_none=True, by_alias=True) == expected def test_yom_hashoah(): @@ -28,7 +28,7 @@ def test_yom_hashoah(): } actual = get_simple_holiday(SimpleHolidayChoices.yom_hashoah.value, PY_DATE) - assert actual.dict(exclude_none=True, by_alias=True) == expected + assert actual.model_dump(exclude_none=True, by_alias=True) == expected def test_yom_hashoah_on_friday(): @@ -41,7 +41,7 @@ def test_yom_hashoah_on_friday(): } actual = get_simple_holiday(SimpleHolidayChoices.yom_hashoah.value, date(2021, 4, 1)) - assert actual.dict(exclude_none=True, by_alias=True) == expected + assert actual.model_dump(exclude_none=True, by_alias=True) == expected def test_yom_hashoah_on_sunday(): @@ -54,7 +54,7 @@ def test_yom_hashoah_on_sunday(): } actual = get_simple_holiday(SimpleHolidayChoices.yom_hashoah.value, date(2024, 4, 1)) - assert actual.dict(exclude_none=True, by_alias=True) == expected + assert actual.model_dump(exclude_none=True, by_alias=True) == expected def test_yom_hazikaron(): @@ -67,7 +67,7 @@ def test_yom_hazikaron(): } actual = get_simple_holiday(SimpleHolidayChoices.yom_hazikaron.value, PY_DATE) - assert actual.dict(exclude_none=True, by_alias=True) == expected + assert actual.model_dump(exclude_none=True, by_alias=True) == expected def test_yom_hazikaron_friday_yom_haatzmaut_shabbat(): @@ -88,8 +88,8 @@ def test_yom_hazikaron_friday_yom_haatzmaut_shabbat(): actual_1 = get_simple_holiday(SimpleHolidayChoices.yom_hazikaron.value, date(2021, 4, 1)) actual_2 = get_simple_holiday(SimpleHolidayChoices.yom_haatzmaut.value, date(2021, 4, 1)) - assert actual_1.dict(exclude_none=True, by_alias=True) == expected_1 - assert actual_2.dict(exclude_none=True, by_alias=True) == expected_2 + assert actual_1.model_dump(exclude_none=True, by_alias=True) == expected_1 + assert actual_2.model_dump(exclude_none=True, by_alias=True) == expected_2 def test_yom_hazikaron_shabbat_yom_haatzmaut_sunday(): @@ -110,8 +110,8 @@ def test_yom_hazikaron_shabbat_yom_haatzmaut_sunday(): actual_1 = get_simple_holiday(SimpleHolidayChoices.yom_hazikaron.value, date(2024, 4, 1)) actual_2 = get_simple_holiday(SimpleHolidayChoices.yom_haatzmaut.value, date(2024, 4, 1)) - assert actual_1.dict(exclude_none=True, by_alias=True) == expected_1 - assert actual_2.dict(exclude_none=True, by_alias=True) == expected_2 + assert actual_1.model_dump(exclude_none=True, by_alias=True) == expected_1 + assert actual_2.model_dump(exclude_none=True, by_alias=True) == expected_2 def test_yom_hazikaron_wednesdey_yom_haatzmaut_thursday(): @@ -132,8 +132,8 @@ def test_yom_hazikaron_wednesdey_yom_haatzmaut_thursday(): actual_1 = get_simple_holiday(SimpleHolidayChoices.yom_hazikaron.value, date(2022, 4, 1)) actual_2 = get_simple_holiday(SimpleHolidayChoices.yom_haatzmaut.value, date(2022, 4, 1)) - assert actual_1.dict(exclude_none=True, by_alias=True) == expected_1 - assert actual_2.dict(exclude_none=True, by_alias=True) == expected_2 + assert actual_1.model_dump(exclude_none=True, by_alias=True) == expected_1 + assert actual_2.model_dump(exclude_none=True, by_alias=True) == expected_2 def test_holiday_ducing_holiday(): @@ -145,7 +145,7 @@ def test_holiday_ducing_holiday(): 'date': date.fromisoformat('2021-11-29') } - actual = get_simple_holiday(SimpleHolidayChoices.chanukah.value, date(2021, 12, 1)).dict(exclude_none=True, by_alias=True) + actual = get_simple_holiday(SimpleHolidayChoices.chanukah.value, date(2021, 12, 1)).model_dump(exclude_none=True, by_alias=True) assert actual == expected @@ -157,5 +157,5 @@ def test_purim_on_first_adar(): }, 'date': date.fromisoformat('2022-03-17') } - actual = get_simple_holiday(SimpleHolidayChoices.purim.value, date(2022, 3, 2)).dict(exclude_none=True, by_alias=True) + actual = get_simple_holiday(SimpleHolidayChoices.purim.value, date(2022, 3, 2)).model_dump(exclude_none=True, by_alias=True) assert actual == expected diff --git a/test/test_engine/test_rosh_chodesh.py b/test/test_engine/test_rosh_chodesh.py index f4405e1..7d377a2 100644 --- a/test/test_engine/test_rosh_chodesh.py +++ b/test/test_engine/test_rosh_chodesh.py @@ -10,11 +10,11 @@ def test_regular_rosh_chodesh(): 'month_name': 'iyar', 'days': [date.fromisoformat('2020-04-24'), date.fromisoformat('2020-04-25')], 'duration': 2, - 'molad': (dt.fromisoformat('2020-04-22T22:58'), 12) + 'molad': ('2020-04-22T22:58', 12) } actual = get_next_rosh_chodesh(PY_DATE) - assert actual.dict(exclude_none=True, by_alias=True) == expected + assert actual.model_dump(exclude_none=True, by_alias=True) == expected def test_rosh_chodesh_during_rosh_chodesh(): @@ -23,11 +23,11 @@ def test_rosh_chodesh_during_rosh_chodesh(): 'month_name': 'iyar', 'days': [date.fromisoformat('2020-04-24'), date.fromisoformat('2020-04-25')], 'duration': 2, - 'molad': (dt.fromisoformat('2020-04-22T22:58'), 12) + 'molad': ('2020-04-22T22:58', 12) } actual = get_next_rosh_chodesh(date(2020, 4, 25)) - assert actual.dict(exclude_none=True, by_alias=True) == expected + assert actual.model_dump(exclude_none=True, by_alias=True) == expected def test_rosh_chodesh_before_rosh_hashana(): @@ -36,8 +36,8 @@ def test_rosh_chodesh_before_rosh_hashana(): 'month_name': 'cheshvan', 'days': [date.fromisoformat('2020-10-18'), date.fromisoformat('2020-10-19')], 'duration': 2, - 'molad': (dt.fromisoformat('2020-10-17T03:23'), 0) + 'molad': ('2020-10-17T03:23', 0) } actual = get_next_rosh_chodesh(date(2020, 9, 1)) - assert actual.dict(exclude_none=True, by_alias=True) == expected + assert actual.model_dump(exclude_none=True, by_alias=True) == expected diff --git a/test/test_engine/test_shabbat.py b/test/test_engine/test_shabbat.py index 165ee5e..b2a523c 100644 --- a/test/test_engine/test_shabbat.py +++ b/test/test_engine/test_shabbat.py @@ -21,7 +21,7 @@ def test_regular_shabbat(): } resp = get_shabbat(LAT, LNG, ZERO_ELEVATION, CL_OFFSET, HavdalaChoices.tzeis_8_5_degrees, PY_DATE) - assert resp.dict(exclude_none=True, by_alias=True) == expected + assert resp.model_dump(exclude_none=True, by_alias=True) == expected def test_shabbat_with_late_cl_warning(): @@ -41,7 +41,7 @@ def test_shabbat_with_late_cl_warning(): resp = get_shabbat(55.5, 37.7, ZERO_ELEVATION, CL_OFFSET, HavdalaChoices.tzeis_8_5_degrees, date(2020, 6, 15)) - assert resp.dict(exclude_none=True, by_alias=True) == expected + assert resp.model_dump(exclude_none=True, by_alias=True) == expected def test_shabbat_with_tzeit_by_chatzot_layla(): @@ -61,7 +61,7 @@ def test_shabbat_with_tzeit_by_chatzot_layla(): resp = get_shabbat(69.77, 25.01, ZERO_ELEVATION, CL_OFFSET, HavdalaChoices.tzeis_8_5_degrees, date(2021, 7, 24)) - assert resp.dict(exclude_none=True, by_alias=True) == expected + assert resp.model_dump(exclude_none=True, by_alias=True) == expected def test_shabbat_with_polar_daynight(): @@ -79,7 +79,7 @@ def test_shabbat_with_polar_daynight(): resp = get_shabbat(76.60, 103.45, ZERO_ELEVATION, CL_OFFSET, HavdalaChoices.tzeis_8_5_degrees, date(2021, 7, 25)) - assert resp.dict(exclude_none=True, by_alias=True) == expected + assert resp.model_dump(exclude_none=True, by_alias=True) == expected def test_shabbat_with_different_parsha(): @@ -113,8 +113,8 @@ def test_shabbat_with_different_parsha(): resp_1 = get_shabbat(LAT, LNG, ZERO_ELEVATION, CL_OFFSET, HavdalaChoices.tzeis_8_5_degrees, date.fromisoformat('2020-05-30')) resp_2 = get_shabbat(37.7, LNG, ZERO_ELEVATION, CL_OFFSET, HavdalaChoices.tzeis_8_5_degrees, date.fromisoformat('2020-05-30')) - assert resp_1.dict(exclude_none=True, by_alias=True) == expected_1 - assert resp_2.dict(exclude_none=True, by_alias=True) == expected_2 + assert resp_1.model_dump(exclude_none=True, by_alias=True) == expected_1 + assert resp_2.model_dump(exclude_none=True, by_alias=True) == expected_2 def test_shabbat_with_yomtov(): @@ -162,6 +162,6 @@ def test_shabbat_with_yomtov(): resp_2 = get_shabbat(37.7, LNG, ZERO_ELEVATION, CL_OFFSET, HavdalaChoices.tzeis_8_5_degrees, date.fromisoformat('2020-05-29')) resp_3 = get_shabbat(37.7, LNG, ZERO_ELEVATION, CL_OFFSET, HavdalaChoices.tzeis_8_5_degrees, date.fromisoformat('2020-04-10')) - assert resp_1.dict(exclude_none=True, by_alias=True) == expected_1 - assert resp_2.dict(exclude_none=True, by_alias=True) == expected_2 - assert resp_3.dict(exclude_none=True, by_alias=True) == expected_3 + assert resp_1.model_dump(exclude_none=True, by_alias=True) == expected_1 + assert resp_2.model_dump(exclude_none=True, by_alias=True) == expected_2 + assert resp_3.model_dump(exclude_none=True, by_alias=True) == expected_3 diff --git a/test/test_engine/test_yomtov.py b/test/test_engine/test_yomtov.py index 9879a08..82f6ca7 100644 --- a/test/test_engine/test_yomtov.py +++ b/test/test_engine/test_yomtov.py @@ -31,7 +31,7 @@ def test_regular_yomtov_in_istael(): 18, HavdalaChoices.tzeis_8_5_degrees ) - assert actual.dict(exclude_none=True, by_alias=True) == expected + assert actual.model_dump(exclude_none=True, by_alias=True) == expected def test_regular_yomtov_in_diaspora(): @@ -64,7 +64,7 @@ def test_regular_yomtov_in_diaspora(): 18, HavdalaChoices.tzeis_8_5_degrees ) - assert actual.dict(exclude_none=True, by_alias=True) == expected + assert actual.model_dump(exclude_none=True, by_alias=True) == expected def test_past_yomtov(): @@ -94,7 +94,7 @@ def test_past_yomtov(): 18, HavdalaChoices.tzeis_8_5_degrees ) - assert actual.dict(exclude_none=True, by_alias=True) == expected + assert actual.model_dump(exclude_none=True, by_alias=True) == expected def test_rosh_hashana_in_diaspora(): @@ -127,7 +127,7 @@ def test_rosh_hashana_in_diaspora(): 18, HavdalaChoices.tzeis_8_5_degrees ) - assert actual.dict(exclude_none=True, by_alias=True) == expected + assert actual.model_dump(exclude_none=True, by_alias=True) == expected def test_pre_shabbat_in_israel(): @@ -160,7 +160,7 @@ def test_pre_shabbat_in_israel(): 18, HavdalaChoices.tzeis_8_5_degrees ) - assert actual.dict(exclude_none=True, by_alias=True) == expected + assert actual.model_dump(exclude_none=True, by_alias=True) == expected def test_pre_shabbat_in_diaspora(): @@ -197,7 +197,7 @@ def test_pre_shabbat_in_diaspora(): 18, HavdalaChoices.tzeis_8_5_degrees ) - assert actual.dict(exclude_none=True, by_alias=True) == expected + assert actual.model_dump(exclude_none=True, by_alias=True) == expected def test_post_shabbat_in_israel(): @@ -230,7 +230,7 @@ def test_post_shabbat_in_israel(): 18, HavdalaChoices.tzeis_8_5_degrees ) - assert actual.dict(exclude_none=True, by_alias=True) == expected + assert actual.model_dump(exclude_none=True, by_alias=True) == expected def test_post_shabbat_in_diaspora(): @@ -278,7 +278,7 @@ def test_post_shabbat_in_diaspora(): 18, HavdalaChoices.tzeis_8_5_degrees ) - assert actual.dict(exclude_none=True, by_alias=True) == expected + assert actual.model_dump(exclude_none=True, by_alias=True) == expected def test_second_yt_is_shabbat(): @@ -322,7 +322,7 @@ def test_second_yt_is_shabbat(): 18, HavdalaChoices.tzeis_8_5_degrees ) - assert actual.dict(exclude_none=True, by_alias=True) == expected + assert actual.model_dump(exclude_none=True, by_alias=True) == expected def test_peesach_part_2_post_shabbat_in_istael(): @@ -362,4 +362,4 @@ def test_peesach_part_2_post_shabbat_in_istael(): 18, HavdalaChoices.tzeis_8_5_degrees ) - assert actual.dict(exclude_none=True, by_alias=True) == expected + assert actual.model_dump(exclude_none=True, by_alias=True) == expected diff --git a/test/test_routers/test_main_router.py b/test/test_routers/test_main_router.py index 9f0d21e..0dffb01 100644 --- a/test/test_routers/test_main_router.py +++ b/test/test_routers/test_main_router.py @@ -98,19 +98,14 @@ def test_shabbat_endpoint(): def test_rosh_chodesh_endpoint(): params = {'date': DATE} expected = { - 'settings': { - 'date': '2020-04-15' - }, + 'settings': {'date': '2020-04-15'}, 'month_name': 'iyar', 'days': [ '2020-04-24', '2020-04-25' ], 'duration': 2, - 'molad': [ - '2020-04-22T22:58', - 12 - ] + 'molad': ['2020-04-22T22:58', 12] } resp = client.get('/rosh_chodesh', params=params) diff --git a/zmanim_api/api_helpers.py b/zmanim_api/api_helpers.py index ed88bb1..1e6e92b 100644 --- a/zmanim_api/api_helpers.py +++ b/zmanim_api/api_helpers.py @@ -1,9 +1,8 @@ +import zoneinfo from enum import Enum from typing import Optional from datetime import date, datetime -import pytz - from zmanim_api.utils import get_tz DATE_PATTERN = r'^\d{1,2}\/\d{1,2}\/\d{1,4}$' @@ -72,7 +71,7 @@ def validate_date_or_get_now(date_: Optional[str], lat: float = 32.09, lng: floa else: tz_name = get_tz(lat, lng) - tz = pytz.timezone(tz_name) + tz = zoneinfo.ZoneInfo(tz_name) response = datetime.now().astimezone(tz).date() return response @@ -86,6 +85,6 @@ def validate_datetime_or_get_now(dt: Optional[str], lat: float, lng: float) -> d raise DateException(e) else: tz_name = get_tz(lat, lng) - tz = pytz.timezone(tz_name) + tz = zoneinfo.ZoneInfo(tz_name) response = datetime.now().astimezone(tz) return response diff --git a/zmanim_api/engine/holidays.py b/zmanim_api/engine/holidays.py index cd6d2bc..c87fc40 100644 --- a/zmanim_api/engine/holidays.py +++ b/zmanim_api/engine/holidays.py @@ -1,4 +1,3 @@ -from typing import Optional, Tuple from datetime import date, timedelta from zmanim.util.geo_location import GeoLocation @@ -119,8 +118,8 @@ def _get_first_day_date(name: str, date_: date, diaspora: bool = True) -> Jewish def fast( name: str, date_: date, - lat: Optional[float], - lng: Optional[float], + lat: float | None, + lng: float | None, elevation: int, ) -> Fast: tz = get_tz(lat, lng) diff --git a/zmanim_api/engine/zmanim_module.py b/zmanim_api/engine/zmanim_module.py index 706706d..fe80092 100644 --- a/zmanim_api/engine/zmanim_module.py +++ b/zmanim_api/engine/zmanim_module.py @@ -1,8 +1,8 @@ +import zoneinfo from typing import Optional from datetime import date, datetime as dt, time, timedelta, datetime import arrow -import pytz from zmanim.util.geo_location import GeoLocation from zmanim.zmanim_calendar import ZmanimCalendar from zmanim.hebrew_calendar.jewish_date import JewishDate @@ -115,7 +115,7 @@ def get_zmanim( zmanim_calc = ZmanimCalculator(lat, lng, date_, elevation) zmanim = {} - for zman_name, is_active in settings.dict().items(): + for zman_name, is_active in settings.model_dump().items(): if not is_active: continue @@ -138,6 +138,6 @@ def is_asur_bemelaha( location = GeoLocation('', lat, lng, tz, elevation) calendar = ZmanimCalendar(geo_location=location, date=dt_.date()) - dt_ = dt_.astimezone(pytz.timezone(tz)) + dt_ = dt_.astimezone(zoneinfo.ZoneInfo(tz)) resp = calendar.is_assur_bemelacha(current_time=dt_, in_israel=is_israel) return BooleanResp(result=resp) diff --git a/zmanim_api/main.py b/zmanim_api/main.py index 7c75152..1d2476d 100644 --- a/zmanim_api/main.py +++ b/zmanim_api/main.py @@ -1,4 +1,5 @@ import logging +from contextlib import asynccontextmanager from os import getenv import sentry_sdk @@ -15,14 +16,22 @@ logger = get_colorized_logger() logger.setLevel(DEBUG) -app = FastAPI(root_path=f'/{ROOT_PATH}', docs_url='/', title='Zmanim API', version='1.0.1') -app.include_router(main_router, tags=['Main']) +@asynccontextmanager +async def lifespan(_: FastAPI): # pragma: no cover + logger.info('STARTING ZMANIM API...') + yield -@app.on_event('startup') -async def on_start(): # pragma: no cover - logger.info('STARTING ZMANIM API...') +app = FastAPI( + lifespan=lifespan, + root_path=f'/{ROOT_PATH}', + docs_url='/', + title='Zmanim API', + version='1.0.1' +) + +app.include_router(main_router, tags=['Main']) @app.middleware('http') # pragma: no cover diff --git a/zmanim_api/models.py b/zmanim_api/models.py index a29dbbd..43ceeeb 100644 --- a/zmanim_api/models.py +++ b/zmanim_api/models.py @@ -1,25 +1,23 @@ from __future__ import annotations -from datetime import datetime, time, date -from typing import List, Optional, Tuple -from pydantic import BaseModel +import json +from datetime import datetime, time, date as Date +from pydantic import BaseModel, field_serializer -class SimpleSettings(BaseModel): - date_: Optional[date] = None - jewish_date: Optional[str] = None - holiday_name: Optional[str] = None - class Config: - fields = {'date_': 'date'} +class SimpleSettings(BaseModel): + date: Date | None = None + jewish_date: str | None = None + holiday_name: str | None = None class Settings(SimpleSettings): - cl_offset: Optional[int] = None - havdala_opinion: Optional[str] = None - coordinates: Optional[Tuple[float, float]] = None - elevation: Optional[int] = None - fast_name: Optional[str] = None - yomtov_name: Optional[str] = None + cl_offset: int | None = None + havdala_opinion: str | None = None + coordinates: tuple[float, float] | None = None + elevation: int | None = None + fast_name: str | None = None + yomtov_name: str | None = None class ZmanimRequest(BaseModel): @@ -46,31 +44,31 @@ class ZmanimRequest(BaseModel): class ZmanimResponse(BaseModel): settings: Settings - alos: Optional[datetime] = None - sunrise: Optional[datetime] = None - misheyakir_10_2: Optional[datetime] = None - sof_zman_shema_ma: Optional[datetime] = None - sof_zman_shema_gra: Optional[datetime] = None - sof_zman_tefila_ma: Optional[datetime] = None - sof_zman_tefila_gra: Optional[datetime] = None - chatzos: Optional[datetime] = None - mincha_gedola: Optional[datetime] = None - mincha_ketana: Optional[datetime] = None - plag_mincha: Optional[datetime] = None - sunset: Optional[datetime] = None - tzeis_5_95_degrees: Optional[datetime] = None - tzeis_8_5_degrees: Optional[datetime] = None - tzeis_42_minutes: Optional[datetime] = None - tzeis_72_minutes: Optional[datetime] = None - chatzot_laila: Optional[datetime] = None - astronomical_hour_ma: Optional[time] = None - astronomical_hour_gra: Optional[time] = None + alos: datetime | None = None + sunrise: datetime | None = None + misheyakir_10_2: datetime | None = None + sof_zman_shema_ma: datetime | None = None + sof_zman_shema_gra: datetime | None = None + sof_zman_tefila_ma: datetime | None = None + sof_zman_tefila_gra: datetime | None = None + chatzos: datetime | None = None + mincha_gedola: datetime | None = None + mincha_ketana: datetime | None = None + plag_mincha: datetime | None = None + sunset: datetime | None = None + tzeis_5_95_degrees: datetime | None = None + tzeis_8_5_degrees: datetime | None = None + tzeis_42_minutes: datetime | None = None + tzeis_72_minutes: datetime | None = None + chatzot_laila: datetime | None = None + astronomical_hour_ma: time | None = None + astronomical_hour_gra: time | None = None class AsurBeMelachaDay(BaseModel): - date: Optional[date] = None - candle_lighting: Optional[datetime] = None - havdala: Optional[datetime] = None + date: Date | None = None + candle_lighting: datetime | None = None + havdala: datetime | None = None class Shabbat(AsurBeMelachaDay): @@ -82,14 +80,19 @@ class Shabbat(AsurBeMelachaDay): class RoshChodesh(BaseModel): settings: SimpleSettings month_name: str - days: List[date] + days: list[Date] duration: int - molad: Tuple[datetime, int] + molad: tuple[datetime, int] + + @field_serializer('molad') + def serialize_molad(self, molad: tuple[datetime, int], _info) -> tuple[str, int]: + return molad[0].isoformat(timespec='minutes'), molad[1] - class Config: - json_encoders = { - datetime: lambda d: d.isoformat(timespec='minutes') - } + # model_config = ConfigDict( + # json_encoders={ + # datetime: lambda d: d.isoformat(timespec='minutes') + # } + # ) class DafYomi(BaseModel): @@ -100,34 +103,34 @@ class DafYomi(BaseModel): class Holiday(BaseModel): settings: SimpleSettings - date: date + date: Date class YomTov(BaseModel): settings: Settings - pre_shabbat: Optional[AsurBeMelachaDay] = None + pre_shabbat: AsurBeMelachaDay | None = None - pesach_eating_chanetz_till: Optional[datetime] = None - pesach_burning_chanetz_till: Optional[datetime] = None + pesach_eating_chanetz_till: datetime | None = None + pesach_burning_chanetz_till: datetime | None = None day_1: AsurBeMelachaDay - day_2: Optional[AsurBeMelachaDay] = None - post_shabbat: Optional[AsurBeMelachaDay] = None - hoshana_rabba: Optional[date] = None + day_2: AsurBeMelachaDay | None = None + post_shabbat: AsurBeMelachaDay | None = None + hoshana_rabba: Date | None = None - pesach_part_2_day_1: Optional[AsurBeMelachaDay] = None - pesach_part_2_day_2: Optional[AsurBeMelachaDay] = None - pesach_part_2_post_shabat: Optional[AsurBeMelachaDay] = None + pesach_part_2_day_1: AsurBeMelachaDay | None = None + pesach_part_2_day_2: AsurBeMelachaDay | None = None + pesach_part_2_post_shabat: AsurBeMelachaDay | None = None class Fast(BaseModel): settings: Settings - moved_fast: Optional[bool] = False - fast_start: Optional[datetime] = None - chatzot: Optional[datetime] = None - havdala_5_95_dgr: Optional[datetime] = None - havdala_8_5_dgr: Optional[datetime] = None - havdala_42_min: Optional[datetime] = None + moved_fast: bool | None = False + fast_start: datetime | None = None + chatzot: datetime | None = None + havdala_5_95_dgr: datetime | None = None + havdala_8_5_dgr: datetime | None = None + havdala_42_min: datetime | None = None class BooleanResp(BaseModel):