From f048a8fdd9413a95064d2b97ab5904b40424c8fd Mon Sep 17 00:00:00 2001 From: mateo Date: Thu, 8 Oct 2026 04:43:21 +0000 Subject: [PATCH] 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> --- scripts/check_type_discipline.py | 3 ++- tests/unit/test_check_type_discipline.py | 11 +++++++++++ type-discipline-budget.json | 2 +- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/scripts/check_type_discipline.py b/scripts/check_type_discipline.py index a9f417f807c..02555f7d4e5 100644 --- a/scripts/check_type_discipline.py +++ b/scripts/check_type_discipline.py @@ -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: ` on the `class` line. @@ -166,6 +166,7 @@ PYDANTIC_BASES: Final = frozenset( "LiteLLMBaseModel", "BaseLiteLLMOpenAIResponseObject", "LiteLLMPydanticObjectBase", + "OpenAIObject", "RootModel", "BaseSettings", ) diff --git a/tests/unit/test_check_type_discipline.py b/tests/unit/test_check_type_discipline.py index bdfb909833f..171e1460b0a 100644 --- a/tests/unit/test_check_type_discipline.py +++ b/tests/unit/test_check_type_discipline.py @@ -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" diff --git a/type-discipline-budget.json b/type-discipline-budget.json index 47b303c41e8..52b7682464b 100644 --- a/type-discipline-budget.json +++ b/type-discipline-budget.json @@ -39,6 +39,6 @@ "limit": 369 }, "LIT015": { - "limit": 1424 + "limit": 1450 } }