Unnecessary else block after return
This commit is contained in:
parent
cc66213e57
commit
e06e288aa0
4 changed files with 9 additions and 16 deletions
|
|
@ -47,7 +47,7 @@ def find_best_app(module):
|
|||
|
||||
if len(matches) == 1:
|
||||
return matches[0]
|
||||
elif len(matches) > 1:
|
||||
if len(matches) > 1:
|
||||
raise NoAppException(
|
||||
"Detected multiple Flask applications in module"
|
||||
f" '{module.__name__}'. Use '{module.__name__}:name'"
|
||||
|
|
@ -233,8 +233,7 @@ def locate_app(module_name, app_name, raise_if_not_found=True):
|
|||
|
||||
if app_name is None:
|
||||
return find_best_app(module)
|
||||
else:
|
||||
return find_app_by_string(module, app_name)
|
||||
return find_app_by_string(module, app_name)
|
||||
|
||||
|
||||
def get_version(ctx, param, value):
|
||||
|
|
|
|||
|
|
@ -82,8 +82,7 @@ class _AppCtxGlobals:
|
|||
"""
|
||||
if default is _sentinel:
|
||||
return self.__dict__.pop(name)
|
||||
else:
|
||||
return self.__dict__.pop(name, default)
|
||||
return self.__dict__.pop(name, default)
|
||||
|
||||
def setdefault(self, name: str, default: t.Any = None) -> t.Any:
|
||||
"""Get the value of an attribute if it is present, otherwise
|
||||
|
|
|
|||
|
|
@ -249,8 +249,7 @@ class Scaffold:
|
|||
"""
|
||||
if self._static_folder is not None:
|
||||
return os.path.join(self.root_path, self._static_folder)
|
||||
else:
|
||||
return None
|
||||
return None
|
||||
|
||||
@static_folder.setter
|
||||
def static_folder(self, value: t.Optional[t.Union[str, os.PathLike]]) -> None:
|
||||
|
|
@ -342,8 +341,7 @@ class Scaffold:
|
|||
"""
|
||||
if self.template_folder is not None:
|
||||
return FileSystemLoader(os.path.join(self.root_path, self.template_folder))
|
||||
else:
|
||||
return None
|
||||
return None
|
||||
|
||||
def open_resource(self, resource: str, mode: str = "rb") -> t.IO[t.AnyStr]:
|
||||
"""Open a resource file relative to :attr:`root_path` for
|
||||
|
|
@ -743,8 +741,7 @@ class Scaffold:
|
|||
|
||||
if issubclass(exc_class, HTTPException):
|
||||
return exc_class, exc_class.code
|
||||
else:
|
||||
return exc_class, None
|
||||
return exc_class, None
|
||||
|
||||
|
||||
def _endpoint_from_view_func(view_func: t.Callable) -> str:
|
||||
|
|
@ -824,11 +821,10 @@ def _find_package_path(import_name):
|
|||
search_locations = iter(root_spec.submodule_search_locations)
|
||||
return os.path.dirname(next(search_locations))
|
||||
# a package (with __init__.py)
|
||||
elif root_spec.submodule_search_locations:
|
||||
if root_spec.submodule_search_locations:
|
||||
return os.path.dirname(os.path.dirname(root_spec.origin))
|
||||
# just a normal module
|
||||
else:
|
||||
return os.path.dirname(root_spec.origin)
|
||||
return os.path.dirname(root_spec.origin)
|
||||
|
||||
# we were unable to find the `package_path` using PEP 451 loaders
|
||||
loader = pkgutil.get_loader(root_mod_name)
|
||||
|
|
|
|||
|
|
@ -54,8 +54,7 @@ class Request(RequestBase):
|
|||
"""Read-only view of the ``MAX_CONTENT_LENGTH`` config key."""
|
||||
if current_app:
|
||||
return current_app.config["MAX_CONTENT_LENGTH"]
|
||||
else:
|
||||
return None
|
||||
return None
|
||||
|
||||
@property
|
||||
def endpoint(self) -> t.Optional[str]:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue