3
0
Fork 0

fix: fix 'inconsistent-return-statements' for pylint

This commit is contained in:
Lance Edgar 2025-08-31 19:44:18 -05:00
parent 45a6c107b0
commit 4e9f7bf479
16 changed files with 67 additions and 23 deletions

6
.pylintrc Normal file
View file

@ -0,0 +1,6 @@
# -*- mode: conf; -*-
[MESSAGES CONTROL]
disable=all
enable=
inconsistent-return-statements,

View file

@ -52,7 +52,7 @@ dependencies = [
[project.optional-dependencies]
continuum = ["Wutta-Continuum"]
docs = ["Sphinx", "furo", "sphinxcontrib-programoutput"]
tests = ["pytest-cov", "tox"]
tests = ["pylint", "pytest", "pytest-cov", "tox"]
[project.entry-points."fanstatic.libraries"]

View file

@ -2,7 +2,7 @@
################################################################################
#
# wuttaweb -- Web App for Wutta Framework
# Copyright © 2024 Lance Edgar
# Copyright © 2024-2025 Lance Edgar
#
# This file is part of Wutta Framework.
#
@ -115,12 +115,12 @@ class WuttaSecurityPolicy:
# fetch user uuid from current session
uuid = self.session_helper.authenticated_userid(request)
if not uuid:
return
return None
# fetch user object from db
user = self.db_session.get(model.User, uuid)
if not user:
return
return None
return user
@ -131,6 +131,7 @@ class WuttaSecurityPolicy:
user = self.identity(request)
if user is not None:
return user.uuid
return None
def remember(self, request, userid, **kw):
return self.session_helper.remember(request, userid, **kw)

View file

@ -2,7 +2,7 @@
################################################################################
#
# wuttaweb -- Web App for Wutta Framework
# Copyright © 2024 Lance Edgar
# Copyright © 2024-2025 Lance Edgar
#
# This file is part of Wutta Framework.
#
@ -48,9 +48,11 @@ else:
request = get_current_request()
if request:
return request.client_addr
return None
def get_user_id(self, uow, session):
""" """
request = get_current_request()
if request and request.user:
return request.user.uuid
return None

View file

@ -2,7 +2,7 @@
################################################################################
#
# wuttaweb -- Web App for Wutta Framework
# Copyright © 2024 Lance Edgar
# Copyright © 2024-2025 Lance Edgar
#
# This file is part of Wutta Framework.
#
@ -537,6 +537,8 @@ class Form:
if widget_type == "notes":
return widgets.NotesWidget(**kwargs)
return None
def set_default_widgets(self):
"""
Set default field widgets, where applicable.
@ -1147,11 +1149,11 @@ class Form:
def get_vue_field_value(self, key):
""" """
if key not in self.fields:
return
return None
dform = self.get_deform()
if key not in dform:
return
return None
field = dform[key]
return make_json_safe(field.cstruct)

View file

@ -2,7 +2,7 @@
################################################################################
#
# wuttaweb -- Web App for Wutta Framework
# Copyright © 2024 Lance Edgar
# Copyright © 2024-2025 Lance Edgar
#
# This file is part of Wutta Framework.
#
@ -49,7 +49,9 @@ class WuttaDateTime(colander.DateTime):
the Buefy datepicker + timepicker widgets.
"""
def deserialize(self, node, cstruct):
def deserialize( # pylint: disable=inconsistent-return-statements
self, node, cstruct
):
""" """
if not cstruct:
return colander.null
@ -376,7 +378,7 @@ class ObjectRef(colander.SchemaType):
``colander.Invalid``.
"""
if not value:
return
return None
if isinstance(value, self.model_class):
return value

View file

@ -2,7 +2,7 @@
################################################################################
#
# wuttaweb -- Web App for Wutta Framework
# Copyright © 2024 Lance Edgar
# Copyright © 2024-2025 Lance Edgar
#
# This file is part of Wutta Framework.
#
@ -2280,6 +2280,8 @@ class Grid:
sorter = self.sort_defaults[0]
return [sorter.sortkey, sorter.sortdir]
return None
def get_vue_filters(self):
"""
Returns a list of Vue-compatible filter definitions.
@ -2422,6 +2424,7 @@ class Grid:
if callable(self.row_class):
return self.row_class(obj, data, i)
return self.row_class
return None
def get_vue_pager_stats(self):
"""

View file

@ -516,6 +516,7 @@ class StringAlchemyFilter(AlchemyFilter):
value = str(value)
if value:
return value
return None
def filter_contains(self, query, value):
"""
@ -583,6 +584,7 @@ class IntegerAlchemyFilter(NumericAlchemyFilter):
return int(value)
except:
pass
return None
class BooleanAlchemyFilter(AlchemyFilter):
@ -619,6 +621,7 @@ class BooleanAlchemyFilter(AlchemyFilter):
""" """
if value is not None:
return bool(value)
return None
def filter_is_true(self, query, value):
"""
@ -686,6 +689,8 @@ class DateAlchemyFilter(AlchemyFilter):
else:
return dt.date()
return None
default_sqlalchemy_filters = {
None: AlchemyFilter,

View file

@ -190,6 +190,7 @@ def default_user_getter(request, db_session=None):
model = app.model
session = db_session or Session()
return session.get(model.User, uuid)
return None
def new_request_set_user(

View file

@ -278,6 +278,8 @@ def get_libver(
if not configured_only:
return "3.1.1"
return None
def get_liburl(
request,
@ -370,7 +372,7 @@ def get_liburl(
return url
if configured_only:
return
return None
version = get_libver(
request, key, prefix=prefix, configured_only=False, default_only=default_only
@ -456,6 +458,8 @@ def get_liburl(
f"https://cdn.jsdelivr.net/npm/@fortawesome/vue-fontawesome@{version}/+esm"
)
return None
def get_csrf_token(request):
"""
@ -523,7 +527,7 @@ def get_model_fields(config, model_class, include_fk=False):
try:
mapper = sa.inspect(model_class)
except sa.exc.NoInspectionAvailable:
return
return None
if include_fk:
fields = [prop.key for prop in mapper.iterate_properties]

View file

@ -2,7 +2,7 @@
################################################################################
#
# wuttaweb -- Web App for Wutta Framework
# Copyright © 2024 Lance Edgar
# Copyright © 2024-2025 Lance Edgar
#
# This file is part of Wutta Framework.
#
@ -149,6 +149,7 @@ class BatchMasterView(MasterView):
if value:
batch_id = int(value)
return f"{batch_id:08d}"
return None
def get_instance_title(self, batch):
""" """

View file

@ -2,7 +2,7 @@
################################################################################
#
# wuttaweb -- Web App for Wutta Framework
# Copyright © 2024 Lance Edgar
# Copyright © 2024-2025 Lance Edgar
#
# This file is part of Wutta Framework.
#
@ -126,7 +126,7 @@ class EmailSettingView(MasterView):
""" """
recips = value
if not recips:
return
return None
if len(recips) < 3:
return ", ".join(recips)

View file

@ -2,7 +2,7 @@
################################################################################
#
# wuttaweb -- Web App for Wutta Framework
# Copyright © 2024 Lance Edgar
# Copyright © 2024-2025 Lance Edgar
#
# This file is part of Wutta Framework.
#
@ -1449,7 +1449,7 @@ class MasterView(View):
grid.set_renderer('my_bool_field', self.grid_render_bool)
"""
if value is None:
return
return None
return "Yes" if value else "No"
@ -1476,7 +1476,7 @@ class MasterView(View):
value = record[key]
if value is None:
return
return None
if value < 0:
fmt = f"(${{:0,.{scale}f}})"
@ -1506,7 +1506,7 @@ class MasterView(View):
value = record[key]
if value is None:
return
return None
return value.strftime(fmt or "%Y-%m-%d %I:%M:%S %p")
@ -1555,7 +1555,7 @@ class MasterView(View):
grid.set_renderer('my_notes_field', self.grid_render_notes, maxlen=50)
"""
if value is None:
return
return None
if len(value) < maxlen:
return value
@ -1910,6 +1910,7 @@ class MasterView(View):
if self.listable:
route_prefix = self.get_route_prefix()
return self.request.route_url(route_prefix, **kwargs)
return None
def set_labels(self, obj):
"""
@ -2073,6 +2074,7 @@ class MasterView(View):
"""
if hasattr(self, "grid_columns"):
return self.grid_columns
return None
def get_grid_data(self, columns=None, session=None):
"""
@ -2104,6 +2106,7 @@ class MasterView(View):
if model_class:
session = session or self.Session()
return session.query(model_class)
return None
def configure_grid(self, grid):
"""
@ -2289,6 +2292,7 @@ class MasterView(View):
"""
if self.is_editable(obj):
return self.get_action_url("edit", obj)
return None
def get_action_url_delete(self, obj, i):
"""
@ -2305,6 +2309,7 @@ class MasterView(View):
"""
if self.is_deletable(obj):
return self.get_action_url("delete", obj)
return None
def is_editable(self, obj):
"""
@ -2386,6 +2391,7 @@ class MasterView(View):
"""
if hasattr(self, "form_fields"):
return self.form_fields
return None
def configure_form(self, form):
"""
@ -2480,6 +2486,7 @@ class MasterView(View):
"""
if hasattr(self, "rows_title"):
return self.rows_title
return None
def make_row_model_grid(self, obj, **kwargs):
"""
@ -2586,6 +2593,7 @@ class MasterView(View):
"""
if hasattr(self, "row_grid_columns"):
return self.row_grid_columns
return None
def get_row_grid_data(self, obj):
"""
@ -2685,6 +2693,7 @@ class MasterView(View):
"""
if hasattr(cls, "model_class"):
return cls.model_class
return None
@classmethod
def get_model_name(cls):
@ -2972,6 +2981,7 @@ class MasterView(View):
"""
if hasattr(cls, "row_model_class"):
return cls.row_model_class
return None
##############################
# configuration

View file

@ -2,7 +2,7 @@
################################################################################
#
# wuttaweb -- Web App for Wutta Framework
# Copyright © 2024 Lance Edgar
# Copyright © 2024-2025 Lance Edgar
#
# This file is part of Wutta Framework.
#
@ -117,6 +117,7 @@ class UpgradeView(MasterView):
return "has-background-warning"
if upgrade.status == enum.UpgradeStatus.FAILURE:
return "has-background-warning"
return None
def configure_form(self, f):
""" """
@ -228,6 +229,7 @@ class UpgradeView(MasterView):
""" """
if filename:
return self.get_upgrade_filepath(upgrade, filename)
return None
def get_upgrade_filepath(self, upgrade, filename=None, create=True):
""" """

View file

@ -104,6 +104,7 @@ class UserView(MasterView):
""" """
if not user.active:
return "has-background-warning"
return None
def is_editable(self, user):
""" """

View file

@ -9,6 +9,10 @@ commands = pytest {posargs}
[testenv:nox]
extras = tests
[testenv:pylint]
basepython = python3.11
commands = pylint wuttaweb
[testenv:coverage]
basepython = python3.11
commands = pytest --cov=wuttaweb --cov-report=html --cov-fail-under=100