Skip to content
Myr

Allow for PathLike types for config file variables

Before adoption: this commit came in with the history the project adopted, so no landing records it.

This follows the Flask practice elsewhere and makes it clear PathLike filenames are valid.

authored by pgjones · committed by pgjones · parent 4911012 · Browse files · 1 file+5 added−3 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+5 added−3 removed

  • other:+5 added−3 removed

1 file+5 added−3 removed

modified:src/flask/config.py+5 added-3 removed
70 unmodified lines
71 the application's :attr:`~flask.Flask.root_path`.72 :param defaults: an optional dictionary of default values73 """7475 def __init__(self, root_path: str, defaults: dict | None = None) -> None:75 def __init__(76 self, root_path: str | os.PathLike, defaults: dict | None = None77 ) -> None:78 super().__init__(defaults or {})79 self.root_path = root_path8081 def from_envvar(self, variable_name: str, silent: bool = False) -> bool:
83 unmodified lines
165 current[tail] = value166167 return True168167 def from_pyfile(self, filename: str, silent: bool = False) -> bool:169 def from_pyfile(self, filename: str | os.PathLike, silent: bool = False) -> bool:170 """Updates the values in the config from a Python file. This function171 behaves as if the file was imported as module with the172 :meth:`from_object` function.173
60 unmodified lines
234 self[key] = getattr(obj, key)235236 def from_file(237 self,236 filename: str,238 filename: str | os.PathLike,239 load: t.Callable[[t.IO[t.Any]], t.Mapping],240 silent: bool = False,241 text: bool = True,242 ) -> bool:
105 unmodified lines