fix: fix 'no-member' for pylint
This commit is contained in:
parent
dd25d98e7d
commit
ad74bede04
7 changed files with 21 additions and 20 deletions
|
@ -3,4 +3,3 @@
|
|||
[MESSAGES CONTROL]
|
||||
disable=fixme,
|
||||
duplicate-code,
|
||||
no-member,
|
||||
|
|
|
@ -407,6 +407,7 @@ class RoleRefsWidget(WuttaCheckboxChoiceWidget):
|
|||
"""
|
||||
|
||||
readonly_template = "readonly/rolerefs"
|
||||
session = None
|
||||
|
||||
def serialize(self, field, cstruct, **kw): # pylint: disable=empty-docstring
|
||||
""" """
|
||||
|
@ -463,6 +464,7 @@ class PermissionsWidget(WuttaCheckboxChoiceWidget):
|
|||
|
||||
template = "permissions"
|
||||
readonly_template = "readonly/permissions"
|
||||
permissions = None
|
||||
|
||||
def serialize(self, field, cstruct, **kw): # pylint: disable=empty-docstring
|
||||
""" """
|
||||
|
|
|
@ -59,9 +59,10 @@ class GridFilter: # pylint: disable=too-many-instance-attributes
|
|||
|
||||
:param request: Current :term:`request` object.
|
||||
|
||||
:param model_property: Property of a model class, representing the
|
||||
column by which to filter. For instance,
|
||||
``model.Person.full_name``.
|
||||
:param nullable: Boolean indicating whether the filter should
|
||||
include ``is_null`` and ``is_not_null`` verbs. If not
|
||||
specified, the column will be inspected (if possible) and use
|
||||
its nullable flag.
|
||||
|
||||
:param \\**kwargs: Any additional kwargs will be set as attributes
|
||||
on the filter instance.
|
||||
|
@ -176,6 +177,7 @@ class GridFilter: # pylint: disable=too-many-instance-attributes
|
|||
label=None,
|
||||
verbs=None,
|
||||
choices=None,
|
||||
nullable=None,
|
||||
default_active=False,
|
||||
default_verb=None,
|
||||
default_value=None,
|
||||
|
@ -196,10 +198,14 @@ class GridFilter: # pylint: disable=too-many-instance-attributes
|
|||
self.verbs = verbs
|
||||
if default_verb:
|
||||
self.default_verb = default_verb
|
||||
self.verb = None # active verb is set later
|
||||
|
||||
# choices
|
||||
self.set_choices(choices or {})
|
||||
|
||||
# nullable
|
||||
self.nullable = nullable
|
||||
|
||||
# value
|
||||
self.default_value = default_value
|
||||
self.value = self.default_value
|
||||
|
@ -398,18 +404,12 @@ class AlchemyFilter(GridFilter):
|
|||
:param model_property: Property of a model class, representing the
|
||||
column by which to filter. For instance,
|
||||
``model.Person.full_name``.
|
||||
|
||||
:param nullable: Boolean indicating whether the filter should
|
||||
include ``is_null`` and ``is_not_null`` verbs. If not
|
||||
specified, the column will be inspected and use its nullable
|
||||
flag.
|
||||
"""
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
nullable = kwargs.pop("nullable", None)
|
||||
self.model_property = kwargs.pop("model_property")
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
self.nullable = nullable
|
||||
if self.nullable is None:
|
||||
columns = self.model_property.prop.columns
|
||||
if len(columns) == 1:
|
||||
|
|
|
@ -398,11 +398,10 @@ class BatchMasterView(MasterView):
|
|||
:attr:`~wuttjamaican:wuttjamaican.db.model.batch.BatchMixin.rows`
|
||||
data.
|
||||
"""
|
||||
session = self.Session()
|
||||
batch = obj
|
||||
row_model_class = self.get_row_model_class()
|
||||
query = self.Session.query(row_model_class).filter(
|
||||
row_model_class.batch == batch
|
||||
)
|
||||
query = session.query(row_model_class).filter(row_model_class.batch == batch)
|
||||
return query
|
||||
|
||||
def configure_row_grid(self, grid): # pylint: disable=empty-docstring
|
||||
|
|
|
@ -399,6 +399,8 @@ class MasterView(View): # pylint: disable=too-many-public-methods
|
|||
# attributes
|
||||
##############################
|
||||
|
||||
model_class = None
|
||||
|
||||
# features
|
||||
listable = True
|
||||
has_grid = True
|
||||
|
@ -526,11 +528,12 @@ class MasterView(View): # pylint: disable=too-many-public-methods
|
|||
* :meth:`redirect_after_create()`
|
||||
"""
|
||||
self.creating = True
|
||||
session = self.Session()
|
||||
form = self.make_model_form(cancel_url_fallback=self.get_index_url())
|
||||
|
||||
if form.validate():
|
||||
obj = self.create_save_form(form)
|
||||
self.Session.flush()
|
||||
session.flush()
|
||||
return self.redirect_after_create(obj)
|
||||
|
||||
context = {
|
||||
|
@ -2702,9 +2705,7 @@ class MasterView(View): # pylint: disable=too-many-public-methods
|
|||
do not set the :attr:`model_class`, then you *must* set the
|
||||
:attr:`model_name`.
|
||||
"""
|
||||
if hasattr(cls, "model_class"):
|
||||
return cls.model_class
|
||||
return None
|
||||
return cls.model_class
|
||||
|
||||
@classmethod
|
||||
def get_model_name(cls):
|
||||
|
|
|
@ -52,7 +52,7 @@ class TestGridFilter(WebTestCase):
|
|||
|
||||
# verb is not set by default, but can be set
|
||||
filtr = self.make_filter(model.Setting.name)
|
||||
self.assertFalse(hasattr(filtr, "verb"))
|
||||
self.assertIsNone(filtr.verb)
|
||||
filtr = self.make_filter(model.Setting.name, verb="foo")
|
||||
self.assertEqual(filtr.verb, "foo")
|
||||
|
||||
|
|
|
@ -624,7 +624,7 @@ class TestMasterView(WebTestCase):
|
|||
view = self.make_view()
|
||||
|
||||
# empty by default
|
||||
self.assertFalse(hasattr(mod.MasterView, "model_class"))
|
||||
self.assertIsNone(mod.MasterView.model_class)
|
||||
data = view.get_grid_data(session=self.session)
|
||||
self.assertEqual(data, [])
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue