class

Analyzer::Python::Quart

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

Quart is an ASGI re-implementation of Flask's API. Decorator, Blueprint, and request-object shapes mirror Flask 1:1, so this analyzer leans on the same tree-sitter helpers as the Flask one and adds two Quart-specific pieces:

  • @app.websocket("/ws") — surfaced as GET + protocol = "ws" so the existing endpoint pipeline carries it through unchanged
  • await request.get_json() / request.json body extraction — the same patterns Flask uses; nothing extra is needed because parameter extraction reads the function body line-by-line and the await prefix doesn't change the access shape.

Constants

ADD_URL_RULE_SCAN_RE = /(#{PYTHON_VAR_NAME_REGEX})\.add_url_rule\s*\((.*)\)\s*$/m
DOTTED_REFERENCE_RE = /^#{DOT_NATION}$/
METHOD_VIEW_DIRECT_RE = /view_func\s*=\s*(#{PYTHON_VAR_NAME_REGEX})\.as_view\s*\(/
METHOD_VIEW_POS_VAR_RE = /^\s*[rf]?['"][^'"]*['"]\s*,\s*[rf]?['"][^'"]*['"]\s*,\s*(#{PYTHON_VAR_NAME_REGEX})(?:\s*,|\s*$)/
METHOD_VIEW_POS_VIEW_RE = /^\s*[rf]?['"][^'"]*['"]\s*,\s*[rf]?['"][^'"]*['"]\s*,\s*(#{PYTHON_VAR_NAME_REGEX})\.as_view\s*\(/
METHOD_VIEW_VAR_RE = /view_func\s*=\s*(#{PYTHON_VAR_NAME_REGEX})/
QUART_INSTANCE_RE = /(#{PYTHON_VAR_NAME_REGEX})(?::#{PYTHON_VAR_NAME_REGEX})?=(?:quart\.)?Quart\(/

Per-line route-discovery patterns. These interpolate only the PYTHON_VAR_NAME_REGEX/DOT_NATION constants, so an inline literal inside the per-line analyze loop recompiled an identical PCRE2 pattern on every source line of every file. Compile once here; the .to_s expansion of the interpolated constants is byte-identical to the previous inline form, so matching behaviour is unchanged.

REGISTER_BLUEPRINT_RE = /(#{PYTHON_VAR_NAME_REGEX})\.register_blueprint\((#{DOT_NATION})/
VIEW_ASSIGN_RE = /(#{PYTHON_VAR_NAME_REGEX})=(#{PYTHON_VAR_NAME_REGEX})\.as_view\(/
VIEW_FUNC_KWARG_RE = /view_func\s*=\s*(#{DOT_NATION})(?:\s*,|\s*\)|\s*$)/

Constant-only interpolation (DOT_NATION) — hoisted so the per-call sites don't recompile them.

WEBSOCKET_ATTRIBUTES = {"websocket" => "GET"}

@app.websocket("/ws") is the only attribute outside the standard HTTP-method set that the tree-sitter extractor needs to surface here. The synthesised method stays GET so the downstream filter logic (which keys off HTTP methods) keeps working; the analyzer rewrites protocol to "ws" later.

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