Skip to content

Commit

Permalink
update type annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
davidism committed May 11, 2021
1 parent 3a5532b commit 1403d35
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/flask/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -704,7 +704,7 @@ def create_jinja_environment(self) -> Environment:
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:
Expand Down
2 changes: 1 addition & 1 deletion src/flask/json/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
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
Expand Down
13 changes: 8 additions & 5 deletions src/flask/templating.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -83,7 +86,7 @@ def _get_source_explained(

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)
Expand Down

0 comments on commit 1403d35

Please sign in to comment.