class

Analyzer::Python::Starlette

Inherits Analyzer::Python::PythonEngine < Analyzer < FileHelper < Reference < Object

Constants

ADD_ROUTE_RE = /(#{DOT_NATION})\.add_(websocket_)?route\s*\((.*)\)/m

Hoisted out of the analyze loops: an interpolated regex literal recompiles (PCRE2 JIT) on every evaluation, and these interpolate only constants. The .to_s expansion is byte-identical to the previous inline form, so matching behaviour is unchanged.

CLASS_METHOD_DEF_RE = /^\s*(?:async\s+)?def\s+(get|post|put|patch|delete|head|options)\s*\(([^)]*)\)/
MOUNT_REGEX = /Mount\s*\(\s*[rf]?['"]([^'"]*)['"]/

Mount('/prefix', routes=[...]) — only the prefix literal is needed; the routes list is scanned via the ongoing line loop while the mount is on the paren stack.

PATH_PARAM_REGEX = /\{([a-zA-Z_][a-zA-Z0-9_]*)(?::[a-zA-Z_][a-zA-Z0-9_]*)?\}/

Path param in a route pattern: {name} or {name:type}. Starlette uses the :type suffix as a converter hint (int, str, float, uuid, path); it is stripped before the param is exposed as a path param.

ROUTE_REGEX = /\b(WebSocketRoute|Route)\s*\(\s*[rf]?['"]([^'"]*)['"]([^)]*)/

Route('/path', handler, methods=[...]) — captures path, and the tail after the path literal so we can inspect methods= and the handler reference. The tail stops at the closing paren on the same line to keep the match cheap; multi-line Route() calls are still covered for the common (path, handler, methods) shape.

TYPED_PATH_PARAM_REGEX = /\{([a-zA-Z_][a-zA-Z0-9_]*):[a-zA-Z_][a-zA-Z0-9_]*\}/

Class methods

tech_name
Source

Instance methods

analyze
Source
tech

Instance-side view of the same declaration. The per-file rescues live on this base class, which has no way to name the analyzer that is running inside them, so a skipped file could not be attributed to a tech. Deriving it from analyzer_for keeps the name written exactly once.

Source