Skip to content

Commit

Permalink
[1.8.0][config] change who gets mypy errors from pydantic 2 to pydant…
Browse files Browse the repository at this point in the history
…ic 1 users (#22527)

context #17443, specifically

> Unless someone is able to find a clever solution it appears the only
choice is to flip who gets the errors at some point.

looking at [pypi download
stats](https://www.pepy.tech/projects/pydantic?versions=2.*&versions=1.*)
pydantic 2 downloads are ballpark 30% more than pydantic 1

so opening this PR to discuss if now / `1.8.0` is the time

## How I Tested These Changes

run `mypy` on
```
from dagster import Config

class MyConfig(Config): ...
```

pydantic 2: no error
pydantic 1: `error: Metaclass conflict: the metaclass of a derived class
must be a (non-strict) subclass of the metaclasses of all its bases
[misc]`

(cherry picked from commit f15a9fd)
  • Loading branch information
alangenfeld authored and jmsanders committed Jul 29, 2024
1 parent ed04f25 commit 0f546d6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
from .type_check_utils import safe_is_subclass

try:
# Pydantic 2.x
from pydantic.main import ModelMetaclass
except ImportError:
# Pydantic 1.x
from pydantic._internal._model_construction import ModelMetaclass # type: ignore
except ImportError:
# Pydantic 2.x
from pydantic.main import ModelMetaclass

if TYPE_CHECKING:
from dagster._config.pythonic_config import PartialResource
Expand Down
4 changes: 2 additions & 2 deletions python_modules/dagster/tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ setenv =
passenv = CI_* COVERALLS_REPO_TOKEN AWS_SECRET_ACCESS_KEY AWS_ACCESS_KEY_ID BUILDKITE* DAGSTER_DOCKER_* GRPC_SERVER_HOST
install_command =
; pyright/mypy invocations type_signature_tests in need commpat mode installs to find types correctly
type_signature_tests: python -m pip install {opts} {packages} --config-settings editable_mode=compat
type_signature_tests: uv pip install {opts} {packages} --config-settings editable_mode=compat
!type_signature_tests: uv pip install {opts} {packages}

deps =
Expand All @@ -27,7 +27,7 @@ deps =
core_tests_pydantic2: pydantic>=2.0.0
model_tests_pydantic1: pydantic!=1.10.7,<2.0.0
model_tests_pydantic2: pydantic>=2.0.0
type_signature_tests: pydantic!=1.10.7,<2.0.0
type_signature_tests: pydantic>=2.0.0
-e ../dagster-test
-e .[mypy,test,pyright]
-e ../dagster-pipes
Expand Down

1 comment on commit 0f546d6

@github-actions
Copy link

Choose a reason for hiding this comment

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

Deploy preview for dagster-docs ready!

✅ Preview
https://dagster-docs-e5jtbvc1n-elementl.vercel.app
https://release-1-8.dagster.dagster-docs.io

Built with commit 0f546d6.
This pull request is being automatically deployed with vercel-action

Please sign in to comment.