Skip to content

Commit ea05065

Browse files
committed
fix BaseProvider.server_settings
1 parent fd3744a commit ea05065

File tree

3 files changed

+28
-36
lines changed

3 files changed

+28
-36
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
from typing import ClassVar, Optional
2+
3+
from pydantic import BaseModel
4+
5+
from ..providers import BaseProvider
6+
7+
8+
def test_provider_classvars():
9+
"""
10+
Asserts that class attributes are not omitted due to parent classes defining
11+
an instance field of the same name. This was a bug present in Pydantic v1,
12+
which led to an issue documented in #558.
13+
14+
This bug is fixed as of `pydantic==2.10.2`, but we will keep this test in
15+
case this behavior changes in future releases.
16+
"""
17+
18+
class Parent(BaseModel):
19+
test: Optional[str] = None
20+
21+
class Base(BaseModel):
22+
test: ClassVar[str]
23+
24+
class Child(Base, Parent):
25+
test: ClassVar[str] = "expected"
26+
27+
assert Child.test == "expected"

packages/jupyter-ai-magics/jupyter_ai_magics/tests/test_provider_metaclass.py

Lines changed: 0 additions & 35 deletions
This file was deleted.

packages/jupyter-ai/jupyter_ai/tests/test_extension.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def ai_extension(jp_serverapp):
6363
# may run in parallel setting it with race condition; because we are not testing
6464
# the `BaseProvider.server_settings` here, we can just mock the setter
6565
settings_mock = mock.PropertyMock()
66-
with mock.patch.object(BaseProvider.__class__, "server_settings", settings_mock):
66+
with mock.patch.object(BaseProvider, "server_settings", settings_mock):
6767
yield ai
6868

6969

0 commit comments

Comments
 (0)