fix(lint): treat the OpenAIObject alias as a LIT015 model base

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
mateo 2026-10-08 04:43:21 +00:00
parent b1638d363a
commit f048a8fdd9
3 changed files with 14 additions and 2 deletions

View file

@ -97,7 +97,7 @@ LIT015 Pydantic model class that is not frozen. Set `frozen=True` in
inherit the frozen setting from in-module model bases, unless their own
configuration overrides it. Detection is name-based: `BaseModel`,
`pydantic.BaseModel`, `LiteLLMBaseModel`, `BaseLiteLLMOpenAIResponseObject`,
`LiteLLMPydanticObjectBase`, `RootModel`, and `BaseSettings` identify
`LiteLLMPydanticObjectBase`, `OpenAIObject`, `RootModel`, and `BaseSettings` identify
models, while `TypedDict` classes are exempt. Replace in-place field writes
with `model_copy(update=...)`. Suppress with `# frozen-ok: <reason>` on the
`class` line.
@ -166,6 +166,7 @@ PYDANTIC_BASES: Final = frozenset(
"LiteLLMBaseModel",
"BaseLiteLLMOpenAIResponseObject",
"LiteLLMPydanticObjectBase",
"OpenAIObject",
"RootModel",
"BaseSettings",
)

View file

@ -760,6 +760,17 @@ def test_settings_config_dict_frozen_true_is_clean(tmp_path):
assert "LIT015" not in _codes(tmp_path, src)
def test_openai_object_base_is_flagged_and_can_be_frozen(tmp_path):
assert "LIT015" in _codes(tmp_path, "class Foo(OpenAIObject):\n x: int\n")
assert "LIT015" not in _codes(
tmp_path,
"from pydantic import ConfigDict\n"
"class Foo(OpenAIObject):\n"
" model_config = ConfigDict(frozen=True)\n"
" x: int\n",
)
def test_same_named_models_use_each_classes_own_override(tmp_path):
src = (
"from pydantic import BaseModel\n"

View file

@ -39,6 +39,6 @@
"limit": 369
},
"LIT015": {
"limit": 1424
"limit": 1450
}
}