From 189fedb0089ba2bc2fc08fc16dcdca3ce9ac0d5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9ophile=20Bastian?= Date: Sat, 15 Nov 2025 21:00:02 +0100 Subject: [PATCH] Web plugin: add type hint for g.lib --- beetsplug/web/__init__.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/beetsplug/web/__init__.py b/beetsplug/web/__init__.py index 1fbb3b0f3..28bc20152 100644 --- a/beetsplug/web/__init__.py +++ b/beetsplug/web/__init__.py @@ -17,9 +17,10 @@ import base64 import json import os +import typing as t import flask -from flask import g, jsonify +from flask import jsonify from unidecode import unidecode from werkzeug.routing import BaseConverter, PathConverter @@ -28,6 +29,17 @@ from beets import ui, util from beets.dbcore.query import PathQuery from beets.plugins import BeetsPlugin +# Type checking hacks + +if t.TYPE_CHECKING: + + class LibraryCtx(flask.ctx._AppCtxGlobals): + lib: beets.library.Library + + g = LibraryCtx() +else: + from flask import g + # Utilities.