Merge pull request #4152 from Yourun-proger/fix
Before adoption: this commit came in with the history the project adopted, so no landing records it.
`static_folder` can be a `pathlib.Path` object
authored by David Lord · committed by GitHub · parents 187f6ce, 9a2adfb · Browse files · 4 files·+8 added−5 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
4 files+8 added−5 removed
- other:+8 added−5 removed
Provenance
- Commit
06cf349- Tree
8da31f8- Author
David Lord <davidism@gmail.com>- Committer
GitHub <noreply@github.com>- Parent 1
187f6ce- Parent 2
9a2adfb
4 files changed+8 added−5 removed
modified:src/flask/app.py+1 added-1 removed
387 unmodified lines388 def __init__(389 self,390 import_name: str,391 static_url_path: t.Optional[str] = None,392- static_folder: t.Optional[str] = "static",392+ static_folder: t.Optional[t.Union[str, os.PathLike]] = "static",393 static_host: t.Optional[str] = None,394 host_matching: bool = False,395 subdomain_matching: bool = False,396 template_folder: t.Optional[str] = "templates",1697 unmodified linesmodified:src/flask/blueprints.py+2 added-1 removed
1+import os2 import typing as t3 from collections import defaultdict4 from functools import update_wrapper5 169 unmodified lines175 def __init__(176 self,177 name: str,178 import_name: str,178- static_folder: t.Optional[str] = None,179+ static_folder: t.Optional[t.Union[str, os.PathLike]] = None,180 static_url_path: t.Optional[str] = None,181 template_folder: t.Optional[str] = None,182 url_prefix: t.Optional[str] = None,183 subdomain: t.Optional[str] = None,426 unmodified linesmodified:src/flask/scaffold.py+3 added-3 removed
90 unmodified lines91 92 def __init__(93 self,94 import_name: str,95- static_folder: t.Optional[str] = None,95+ static_folder: t.Optional[t.Union[str, os.PathLike]] = None,96 static_url_path: t.Optional[str] = None,97 template_folder: t.Optional[str] = None,98 root_path: t.Optional[str] = None,99 ):100 #: The name of the package or module that this object belongs101 #: to. Do not change this once it is set by the constructor.102 self.import_name = import_name103 104- self.static_folder = static_folder104+ self.static_folder = static_folder # type: ignore105 self.static_url_path = static_url_path106 107 #: The path to the templates folder, relative to108 #: :attr:`root_path`, to add to the template loader. ``None`` if147 unmodified lines256 else:257 return None258 259 @static_folder.setter260- def static_folder(self, value: t.Optional[str]) -> None:260+ def static_folder(self, value: t.Optional[t.Union[str, os.PathLike]]) -> None:261 if value is not None:262 value = os.fspath(value).rstrip(r"\/")263 264 self._static_folder = value611 unmodified linesmodified:CHANGES.rst+2 added
11 unmodified lines12 decorators to accept functions with no arguments. :issue:`4098`13 - Support View and MethodView instances with async handlers. :issue:`4112`14 - Enhance typing of ``app.errorhandler`` decorator. :issue:`4095`15 - Fix registering a blueprint twice with differing names. :issue:`4124`16+- Fix the type of ``static_folder`` to accept ``pathlib.Path``.17+ :issue:`4150`18 19 20 Version 2.0.121 -------------1154 unmodified lines