Web plugin: add type hint for g.lib

This commit is contained in:
Théophile Bastian 2025-11-15 21:00:02 +01:00
parent 666c412b0e
commit 189fedb008

View file

@ -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.