fix: use ConfigDict instead of class-based Config in RequestContext#522
fix: use ConfigDict instead of class-based Config in RequestContext#522citizen204 wants to merge 2 commits into
Conversation
Pydantic V2 deprecated class-based model Config in favor of model_config = ConfigDict(...). Replace the inner Config class in RequestContext with the ConfigDict pattern to silence the deprecation warning emitted on import. Fixes aws#320
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #522 +/- ##
=======================================
Coverage ? 89.20%
=======================================
Files ? 96
Lines ? 8441
Branches ? 1256
=======================================
Hits ? 7530
Misses ? 586
Partials ? 325
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Nice — this is the idiomatic V2 pattern and matches the existing One suggestion to lock it in: add a regression test in |
…RequestContext
Instantiate RequestContext under warnings.simplefilter("error", PydanticDeprecatedSince20)
to ensure class-based Config never silently creeps back in.
Addresses review feedback from valter-silva-au on aws#522.
Summary
RequestContextinsrc/bedrock_agentcore/runtime/context.pyuses the Pydantic V1-style innerclass Configto setarbitrary_types_allowed = True. Pydantic V2 deprecated this pattern and emits aPydanticDeprecatedSince20warning on every import ofBedrockAgentCoreApp, adding noise to user applications and test suites.Replace the inner
Configclass withmodel_config = ConfigDict(arbitrary_types_allowed=True)— the idiomatic Pydantic V2 pattern — so the warning is no longer emitted.Fixes #320
Changes
src/bedrock_agentcore/runtime/context.py: importConfigDictfrompydantic; replaceclass Configwithmodel_config = ConfigDict(arbitrary_types_allowed=True)