Skip to content
Snippets Groups Projects
Commit 11e761e9 authored by Wilbur, Spencer Franklin's avatar Wilbur, Spencer Franklin
Browse files

Updated the fastapi package which required a few changes to the file...

Updated the fastapi package which required a few changes to the file pydantic_utcdatetime.py module. The module now contains a workaround to deal with the way pydantic manages the UTCDateTime string. This is a new issue that was caused by updating to fastapi version 0.109.2.
parent 7e65eb09
No related branches found
No related tags found
1 merge request!291Committing two new files, FDSNSNCL and FDSNFactory. The factory is modeled...
...@@ -46,12 +46,38 @@ def format_utcdatetime(o: UTCDateTime) -> str: ...@@ -46,12 +46,38 @@ def format_utcdatetime(o: UTCDateTime) -> str:
def parse_utcdatetime( def parse_utcdatetime(
value: Union[datetime, float, int, str, UTCDateTime] value: Union[datetime, float, int, str, UTCDateTime, Dict]
) -> UTCDateTime: ) -> UTCDateTime:
try: if isinstance(value, UTCDateTime):
return UTCDateTime(value) # If the value is already a UTCDateTime, return it directly
except: return value
raise UTCDateTimeError() elif isinstance(value, dict):
# Handle the nanosecond dictionary format
try:
# Assuming the dictionary format is something like {'_UTCDateTime__ns': 1598918401000000000}
ns = value.get("_UTCDateTime__ns")
if ns is not None:
return UTCDateTime(ns / 1e9) # Convert nanoseconds to seconds
except Exception as e:
raise UTCDateTimeError() from e
else:
# Handle other formats (datetime, float, int, str)
try:
return UTCDateTime(value)
except Exception:
raise UTCDateTimeError()
raise UTCDateTimeError() # Raise an error if none of the above conditions are met
# Code below is what was used to parse UTCDateTime value for pydantic before version 109 break.
# def parse_utcdatetime(
# value: Union[datetime, float, int, str, UTCDateTime]
# ) -> UTCDateTime:
# try:
# return UTCDateTime(value)
# except:
# raise UTCDateTimeError()
register_custom_pydantic_type( register_custom_pydantic_type(
......
...@@ -648,25 +648,23 @@ test = ["pytest (>=6)"] ...@@ -648,25 +648,23 @@ test = ["pytest (>=6)"]
[[package]] [[package]]
name = "fastapi" name = "fastapi"
version = "0.1.17" version = "0.109.2"
description = "FastAPI framework, high performance, easy to learn, fast to code, ready for production" description = "FastAPI framework, high performance, easy to learn, fast to code, ready for production"
category = "main" category = "main"
optional = false optional = false
python-versions = ">=3.6" python-versions = ">=3.8"
files = [ files = [
{file = "fastapi-0.1.17-py3-none-any.whl", hash = "sha256:a6aaad2f60684477480ac9d7a1c95e67f4696a722f184db467494bfdd5b8f29d"}, {file = "fastapi-0.109.2-py3-none-any.whl", hash = "sha256:2c9bab24667293b501cad8dd388c05240c850b58ec5876ee3283c47d6e1e3a4d"},
{file = "fastapi-0.1.17.tar.gz", hash = "sha256:a9a9b6cc32c38bab27a6549b94c44a30c70b485bc789d03de3aa8725f3394be5"}, {file = "fastapi-0.109.2.tar.gz", hash = "sha256:f3817eac96fe4f65a2ebb4baa000f394e55f5fccdaf7f75250804bc58f354f73"},
] ]
[package.dependencies] [package.dependencies]
pydantic = ">=0.17" pydantic = ">=1.7.4,<1.8 || >1.8,<1.8.1 || >1.8.1,<2.0.0 || >2.0.0,<2.0.1 || >2.0.1,<2.1.0 || >2.1.0,<3.0.0"
starlette = ">=0.9.7" starlette = ">=0.36.3,<0.37.0"
typing-extensions = ">=4.8.0"
[package.extras] [package.extras]
all = ["aiofiles", "email_validator", "graphene", "itsdangerous", "jinja2", "python-multipart", "pyyaml", "requests", "ujson", "ujson", "uvicorn"] all = ["email-validator (>=2.0.0)", "httpx (>=0.23.0)", "itsdangerous (>=1.1.0)", "jinja2 (>=2.11.2)", "orjson (>=3.2.1)", "pydantic-extra-types (>=2.0.0)", "pydantic-settings (>=2.0.0)", "python-multipart (>=0.0.7)", "pyyaml (>=5.3.1)", "ujson (>=4.0.1,!=4.0.2,!=4.1.0,!=4.2.0,!=4.3.0,!=5.0.0,!=5.1.0)", "uvicorn[standard] (>=0.12.0)"]
dev = ["passlib[bcrypt]", "pyjwt"]
doc = ["markdown-include", "mkdocs", "mkdocs-material"]
test = ["black", "email_validator", "isort", "mypy", "pytest (>=4.0.0)", "pytest-cov", "requests"]
[[package]] [[package]]
name = "fonttools" name = "fonttools"
...@@ -2281,14 +2279,14 @@ SQLAlchemy = ">=0.9.0" ...@@ -2281,14 +2279,14 @@ SQLAlchemy = ">=0.9.0"
[[package]] [[package]]
name = "starlette" name = "starlette"
version = "0.37.1" version = "0.36.3"
description = "The little ASGI library that shines." description = "The little ASGI library that shines."
category = "main" category = "main"
optional = false optional = false
python-versions = ">=3.8" python-versions = ">=3.8"
files = [ files = [
{file = "starlette-0.37.1-py3-none-any.whl", hash = "sha256:92a816002d4e8c552477b089520e3085bb632e854eb32cef99acb6f6f7830b69"}, {file = "starlette-0.36.3-py3-none-any.whl", hash = "sha256:13d429aa93a61dc40bf503e8c801db1f1bca3dc706b10ef2434a36123568f044"},
{file = "starlette-0.37.1.tar.gz", hash = "sha256:345cfd562236b557e76a045715ac66fdc355a1e7e617b087834a76a87dcc6533"}, {file = "starlette-0.36.3.tar.gz", hash = "sha256:90a671733cfb35771d8cc605e0b679d23b992f8dcfad48cc60b38cb29aeb7080"},
] ]
[package.dependencies] [package.dependencies]
...@@ -2651,4 +2649,4 @@ pycurl = ["pycurl"] ...@@ -2651,4 +2649,4 @@ pycurl = ["pycurl"]
[metadata] [metadata]
lock-version = "2.0" lock-version = "2.0"
python-versions = ">=3.8,<=3.11.*" python-versions = ">=3.8,<=3.11.*"
content-hash = "6208092fdaca4822a9eea892ecf20f293c1330220a4877027a4f570de5b43c4d" content-hash = "c787881982d4b282c5878f8c62bfadea9734c093e98b8b17278afb70263284fd"
...@@ -36,7 +36,7 @@ alembic = "^1.8.1" ...@@ -36,7 +36,7 @@ alembic = "^1.8.1"
Authlib = "^1.1.0" Authlib = "^1.1.0"
cryptography = "^42.0.0" cryptography = "^42.0.0"
databases = {extras = ["mysql", "sqlite"], version = "^0.6.1"} databases = {extras = ["mysql", "sqlite"], version = "^0.6.1"}
fastapi = "^0.1.0" fastapi = "^0.109.1"
gunicorn = "^20.1.0" gunicorn = "^20.1.0"
httpx = "0.23.0" httpx = "0.23.0"
# 2022-10-24 pin sqlalchemy to 1.4.41 for now # 2022-10-24 pin sqlalchemy to 1.4.41 for now
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment