From 433e00fff9a512aac5b024bbb7a117e344b7b6c9 Mon Sep 17 00:00:00 2001 From: 07pepa <9963200+07pepa@users.noreply.github.com> Date: Sat, 23 Nov 2024 09:06:59 +0100 Subject: [PATCH] Fix AnyUrl not being encodable --- .github/workflows/github-actions-tests.yml | 2 +- beanie/odm/utils/encoder.py | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/github-actions-tests.yml b/.github/workflows/github-actions-tests.yml index 1c9bbec7c..348433fb6 100644 --- a/.github/workflows/github-actions-tests.yml +++ b/.github/workflows/github-actions-tests.yml @@ -16,7 +16,7 @@ jobs: matrix: python-version: [ "3.8", "3.9", "3.10", "3.11", "3.12", "3.13" ] mongodb-version: [4.4, 5.0, 6.0, 7.0, 8.0 ] - pydantic-version: [ "1.10.18", "2.9.2" ] + pydantic-version: [ "1.10.18", "2.10.1" ] runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 diff --git a/beanie/odm/utils/encoder.py b/beanie/odm/utils/encoder.py index 87dffe530..dcb2d2ada 100644 --- a/beanie/odm/utils/encoder.py +++ b/beanie/odm/utils/encoder.py @@ -21,6 +21,7 @@ import bson import pydantic +from pydantic import AnyUrl import beanie from beanie.odm.fields import Link, LinkTypes @@ -45,6 +46,7 @@ decimal.Decimal: bson.Decimal128, uuid.UUID: bson.Binary.from_uuid, re.Pattern: bson.Regex.from_native, + AnyUrl: str, } if IS_PYDANTIC_V2: from pydantic_core import Url