From fdeb0eeeb2660405169f65a6bc2b4e1e57bdfe9a Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Sun, 31 Aug 2025 20:20:01 -0500 Subject: [PATCH] fix: fix 'no-else-return' for pylint --- .pylintrc | 1 + src/wuttaweb/util.py | 24 +++++++++++------------ src/wuttaweb/views/auth.py | 3 +-- src/wuttaweb/views/master.py | 38 +++++++++++++++++------------------- 4 files changed, 32 insertions(+), 34 deletions(-) diff --git a/.pylintrc b/.pylintrc index e9784ac..a0fcb74 100644 --- a/.pylintrc +++ b/.pylintrc @@ -4,6 +4,7 @@ disable=all enable= inconsistent-return-statements, + no-else-return, too-many-branches, too-many-instance-attributes, too-many-return-statements, diff --git a/src/wuttaweb/util.py b/src/wuttaweb/util.py index 2928dde..4906da7 100644 --- a/src/wuttaweb/util.py +++ b/src/wuttaweb/util.py @@ -401,57 +401,57 @@ def get_liburl( # pylint: disable=too-many-return-statements,too-many-branches return liburl + static.buefy_js.relpath return f"https://unpkg.com/buefy@{version}/dist/buefy.min.js" - elif key == "buefy.css": + if key == "buefy.css": if static and hasattr(static, "buefy_css"): return liburl + static.buefy_css.relpath return f"https://unpkg.com/buefy@{version}/dist/buefy.min.css" - elif key == "vue": + if key == "vue": if static and hasattr(static, "vue_js"): return liburl + static.vue_js.relpath return f"https://unpkg.com/vue@{version}/dist/vue.min.js" - elif key == "vue_resource": + if key == "vue_resource": if static and hasattr(static, "vue_resource_js"): return liburl + static.vue_resource_js.relpath return f"https://cdn.jsdelivr.net/npm/vue-resource@{version}" - elif key == "fontawesome": + if key == "fontawesome": if static and hasattr(static, "fontawesome_js"): return liburl + static.fontawesome_js.relpath return f"https://use.fontawesome.com/releases/v{version}/js/all.js" - elif key == "bb_vue": + if key == "bb_vue": if static and hasattr(static, "bb_vue_js"): return liburl + static.bb_vue_js.relpath return f"https://unpkg.com/vue@{version}/dist/vue.esm-browser.prod.js" - elif key == "bb_oruga": + if key == "bb_oruga": if static and hasattr(static, "bb_oruga_js"): return liburl + static.bb_oruga_js.relpath return f"https://unpkg.com/@oruga-ui/oruga-next@{version}/dist/oruga.mjs" - elif key == "bb_oruga_bulma": + if key == "bb_oruga_bulma": if static and hasattr(static, "bb_oruga_bulma_js"): return liburl + static.bb_oruga_bulma_js.relpath return f"https://unpkg.com/@oruga-ui/theme-bulma@{version}/dist/bulma.js" - elif key == "bb_oruga_bulma_css": + if key == "bb_oruga_bulma_css": if static and hasattr(static, "bb_oruga_bulma_css"): return liburl + static.bb_oruga_bulma_css.relpath return f"https://unpkg.com/@oruga-ui/theme-bulma@{version}/dist/bulma.css" - elif key == "bb_fontawesome_svg_core": + if key == "bb_fontawesome_svg_core": if static and hasattr(static, "bb_fontawesome_svg_core_js"): return liburl + static.bb_fontawesome_svg_core_js.relpath return f"https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-svg-core@{version}/+esm" - elif key == "bb_free_solid_svg_icons": + if key == "bb_free_solid_svg_icons": if static and hasattr(static, "bb_free_solid_svg_icons_js"): return liburl + static.bb_free_solid_svg_icons_js.relpath return f"https://cdn.jsdelivr.net/npm/@fortawesome/free-solid-svg-icons@{version}/+esm" - elif key == "bb_vue_fontawesome": + if key == "bb_vue_fontawesome": if static and hasattr(static, "bb_vue_fontawesome_js"): return liburl + static.bb_vue_fontawesome_js.relpath return ( @@ -581,7 +581,7 @@ def make_json_safe(value, key=None, warn=True): if value is colander.null: return None - elif isinstance(value, dict): + if isinstance(value, dict): # recursively convert dict parent = dict(value) for key, value in parent.items(): diff --git a/src/wuttaweb/views/auth.py b/src/wuttaweb/views/auth.py index 957ffeb..a2d265c 100644 --- a/src/wuttaweb/views/auth.py +++ b/src/wuttaweb/views/auth.py @@ -86,8 +86,7 @@ class AuthView(View): headers = login_user(self.request, user) return self.redirect(referrer, headers=headers) - else: - self.request.session.flash("Invalid user credentials", "error") + self.request.session.flash("Invalid user credentials", "error") return { "index_title": self.app.get_title(), diff --git a/src/wuttaweb/views/master.py b/src/wuttaweb/views/master.py index 87e8d6e..a4b2b7d 100644 --- a/src/wuttaweb/views/master.py +++ b/src/wuttaweb/views/master.py @@ -483,15 +483,15 @@ class MasterView(View): context["pager_stats"] = grid.get_vue_pager_stats() return self.json_response(context) - else: # full, not partial + # full, not partial - # nb. when user asks to reset view, it is via the query - # string. if so we then redirect to discard that. - if self.request.GET.get("reset-view"): + # nb. when user asks to reset view, it is via the query + # string. if so we then redirect to discard that. + if self.request.GET.get("reset-view"): - # nb. we want to preserve url hash if applicable - kw = {"_query": None, "_anchor": self.request.GET.get("hash")} - return self.redirect(self.request.current_route_url(**kw)) + # nb. we want to preserve url hash if applicable + kw = {"_query": None, "_anchor": self.request.GET.get("hash")} + return self.redirect(self.request.current_route_url(**kw)) context["grid"] = grid @@ -801,19 +801,17 @@ class MasterView(View): self.delete_bulk_action(data) return self.redirect(self.get_index_url()) - else: - - # start thread for delete; show progress page - route_prefix = self.get_route_prefix() - key = f"{route_prefix}.delete_bulk" - progress = self.make_progress(key, success_url=self.get_index_url()) - thread = threading.Thread( - target=self.delete_bulk_thread, - args=(data,), - kwargs={"progress": progress}, - ) - thread.start() - return self.render_progress(progress) + # start thread for delete; show progress page + route_prefix = self.get_route_prefix() + key = f"{route_prefix}.delete_bulk" + progress = self.make_progress(key, success_url=self.get_index_url()) + thread = threading.Thread( + target=self.delete_bulk_thread, + args=(data,), + kwargs={"progress": progress}, + ) + thread.start() + return self.render_progress(progress) def delete_bulk_thread(self, query, success_url=None, progress=None): """ """