Fix deprecated=False override precedence for included routes#15183
Fix deprecated=False override precedence for included routes#15183dipenpadhiyar wants to merge 2 commits intofastapi:masterfrom
Conversation
|
This PR fixes a logic bug in Could a maintainer please add the |
|
I'm not sure this is a bug. @dipenpadhiyar , what is your use case? |
|
Orb Code Review (powered by GLM 5.1 on Orb Cloud) Review of PR #15183: Fix deprecated=False override precedence for included routesNice bug fix — correctly handles the case where a child route explicitly sets The bug ✅ correctly identifiedUsing deprecated=False or self.deprecated=True # → True (wrong!)The fix ✅Using
Test ✅Good test case — verifies that a route with Minor readability note 💡The nested ternary in the include logic works but is slightly hard to parse at a glance: deprecated=(
route.deprecated
if route.deprecated is not None
else self.deprecated
if deprecated is None
else deprecated
)Adding parentheses could help future readers: deprecated=(
route.deprecated if route.deprecated is not None
else (self.deprecated if deprecated is None else deprecated)
)Not blocking — just a readability suggestion. SummaryClean, focused bug fix with test coverage. The Assessment: approve |
Summary
Fix
deprecatedprecedence when including routers so an explicitdeprecated=Falseon a route is not overridden by a parent app or router with
deprecated=True.This aligns behavior with expected precedence: route-level configuration should
override parent settings.
Repro
Changes
Preserve explicit non-None deprecated values when merging route, router, and app settings
Add a regression test for deprecated=False overriding parent deprecated=True