Skip to content

Commit 189fedb

Browse files
committed
Web plugin: add type hint for g.lib
1 parent 666c412 commit 189fedb

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

beetsplug/web/__init__.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@
1717
import base64
1818
import json
1919
import os
20+
import typing as t
2021

2122
import flask
22-
from flask import g, jsonify
23+
from flask import jsonify
2324
from unidecode import unidecode
2425
from werkzeug.routing import BaseConverter, PathConverter
2526

@@ -28,6 +29,17 @@
2829
from beets.dbcore.query import PathQuery
2930
from beets.plugins import BeetsPlugin
3031

32+
# Type checking hacks
33+
34+
if t.TYPE_CHECKING:
35+
36+
class LibraryCtx(flask.ctx._AppCtxGlobals):
37+
lib: beets.library.Library
38+
39+
g = LibraryCtx()
40+
else:
41+
from flask import g
42+
3143
# Utilities.
3244

3345

0 commit comments

Comments
 (0)