Skip to content

Conversation

@07pepa
Copy link
Member

@07pepa 07pepa commented May 6, 2025

remove pydantic v1 and migrate to uv

CAPITAINMARVEL
CAPITAINMARVEL previously approved these changes May 9, 2025
Copy link

@CAPITAINMARVEL CAPITAINMARVEL left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good

- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: actions/checkout@v4
- name: Set up Python ${{ inputs.python-version }}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be matrix instead, don't know why I put inputs in my review on the Beanie repo, probably I saw it in some tutorial so made an unintentional mistake...

Suggested change
- name: Set up Python ${{ inputs.python-version }}
- name: Set up Python ${{ matrix.python-version }}

python-version: ${{ matrix.python-version }}
- name: Run image
uses: abatilo/actions-poetry@v2
python-version: ${{ inputs.python-version }}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as previous comment, otherwise the correct Python version wouldn't be picked up by the CI.

Suggested change
python-version: ${{ inputs.python-version }}
python-version: ${{ matrix.python-version }}

repos:
- repo: https://github.com/ambv/black
rev: 22.12.0
- repo: https://github.com/charliermarsh/ruff-pre-commit

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- repo: https://github.com/charliermarsh/ruff-pre-commit
- repo: https://github.com/astral-sh/ruff-pre-commit

- repo: https://github.com/ambv/black
rev: 22.12.0
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.11.8

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Current latest.

Suggested change
rev: v0.11.8
rev: v0.11.10

import pydantic_core
from pydantic import BaseModel, PrivateAttr, ValidationError, TypeAdapter
from pydantic import BaseModel, PrivateAttr, TypeAdapter, ValidationError
from pydantic._internal import _fields

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I realize this comment is not related to the functionality this PR introduces but, I'm really struggling to see why do we need to import from Pydantic internal stuff.
The only method we use is on ln 76, the is_valid_field_name method and we could simply "vendor it in" ourselves as a helper method.

pyproject.toml Outdated
{name = "Roman Right", email = "[email protected]"},
]
license = {text = "Apache-2.0"}
requires-python = "<4.0,>=3.9"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would revert this since it reads more naturally to me.

Suggested change
requires-python = "<4.0,>=3.9"
requires-python = ">=3.9,<4.0"

pyproject.toml Outdated
"mypy>=1.15.0",
"pytest<8.0.0,>=7.2.0",
"pytest-cov>=6.1.1",
"pytest-sugar<2.0.0,>=1.0.0",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where does this pytest-sugar dependency come from?
Since we don't use it on the Beanie repo I suggest that we don't use it here either.

"pydantic>=2.10.0,<3.0",
]
name = "lazy-model"
version = "0.3.0"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like this project doesn't have the same setup as the Beanie project with regards to SemVer uplifts.
Therefore, it is needed to manually update the version specifier when commiting any change.

Riverfount
Riverfount previously approved these changes Jul 8, 2025
Copy link

@Riverfount Riverfount left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GTM

@staticxterm
Copy link

Generally it also looks good to me functionality wise, but the CI testing is broken and my comment for the .github/workflows/github-actions-tests.yml file still stands.
You can see the warnings if you click on the "Setup python" step for each of the tests:

Warning: Neither 'python-version' nor 'python-version-file' inputs were supplied. Attempting to find '.python-version' file.
Warning: .python-version doesn't exist.
Warning: The `python-version` input is not set.  The version of Python currently in `PATH` will be used.

It would always select and run the tests with the Python version available from the base image, you can verify this if you check the "run tests" step for each of the tests:

Using CPython 3.12.3 interpreter at: /usr/bin/python3

@07pepa 07pepa dismissed stale reviews from Riverfount and CAPITAINMARVEL via 4fdd049 August 7, 2025 18:07
@07pepa 07pepa force-pushed the remove-pydanic1 branch 2 times, most recently from 4fdd049 to cae4426 Compare August 7, 2025 18:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants