MCPcopy
hub / github.com/fastapi/fastapi / effective_candidates

Method effective_candidates

fastapi/routing.py:1583–1602  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1581 _effective_low_priority_routes_version: int | None = None
1582
1583 def effective_candidates(self) -> list["_EffectiveRouteContext | _IncludedRouter"]:
1584 routes_version = self.original_router._get_routes_version()
1585 if routes_version == self._effective_candidates_version:
1586 return self._effective_candidates
1587 self._effective_candidates = []
1588 candidates = self.original_router.routes
1589 for route in candidates:
1590 if isinstance(route, _IncludedRouter):
1591 child_context = self.include_context.combine(route.include_context)
1592 child_branch = _IncludedRouter(
1593 original_router=route.original_router,
1594 include_context=child_context,
1595 )
1596 self._effective_candidates.append(child_branch)
1597 continue
1598 route_context = self._build_effective_context(route)
1599 if route_context is not None:
1600 self._effective_candidates.append(route_context)
1601 self._effective_candidates_version = routes_version
1602 return self._effective_candidates
1603
1604 def effective_low_priority_routes(self) -> list["_EffectiveRouteContext"]:
1605 routes_version = self.original_router._get_routes_version()

Calls 4

_IncludedRouterClass · 0.85
_get_routes_versionMethod · 0.80
combineMethod · 0.80