update type annotations

This commit is contained in:
David Lord 2021-05-11 14:41:45 -07:00
parent 3a5532b4ed
commit 1403d35e2a
No known key found for this signature in database
GPG Key ID: 7A1C87E3F5BC42A8
3 changed files with 10 additions and 7 deletions

View File

@ -704,7 +704,7 @@ class Flask(Scaffold):
session=session,
g=g,
)
rv.policies["json.dumps_function"] = json.dumps # type: ignore
rv.policies["json.dumps_function"] = json.dumps
return rv
def create_global_jinja_loader(self) -> DispatchingJinjaLoader:

View File

@ -5,7 +5,7 @@ import uuid
import warnings
from datetime import date
from jinja2.utils import htmlsafe_json_dumps as _jinja_htmlsafe_dumps # type: ignore
from jinja2.utils import htmlsafe_json_dumps as _jinja_htmlsafe_dumps
from werkzeug.http import http_date
from ..globals import current_app

View File

@ -51,18 +51,21 @@ class DispatchingJinjaLoader(BaseLoader):
def __init__(self, app: "Flask") -> None:
self.app = app
def get_source(
def get_source( # type: ignore
self, environment: Environment, template: str
) -> t.Tuple[str, t.Optional[str], t.Callable]:
) -> t.Tuple[str, t.Optional[str], t.Optional[t.Callable]]:
if self.app.config["EXPLAIN_TEMPLATE_LOADING"]:
return self._get_source_explained(environment, template)
return self._get_source_fast(environment, template)
def _get_source_explained(
self, environment: Environment, template: str
) -> t.Tuple[str, t.Optional[str], t.Callable]:
) -> t.Tuple[str, t.Optional[str], t.Optional[t.Callable]]:
attempts = []
trv = None
rv: t.Optional[t.Tuple[str, t.Optional[str], t.Optional[t.Callable[[], bool]]]]
trv: t.Optional[
t.Tuple[str, t.Optional[str], t.Optional[t.Callable[[], bool]]]
] = None
for srcobj, loader in self._iter_loaders(template):
try:
@ -83,7 +86,7 @@ class DispatchingJinjaLoader(BaseLoader):
def _get_source_fast(
self, environment: Environment, template: str
) -> t.Tuple[str, t.Optional[str], t.Callable]:
) -> t.Tuple[str, t.Optional[str], t.Optional[t.Callable]]:
for _srcobj, loader in self._iter_loaders(template):
try:
return loader.get_source(environment, template)