Skip to content

Commit

Permalink
276 - Converted local function using closure to be callable class
Browse files Browse the repository at this point in the history
  • Loading branch information
dineshtrivedi committed Jan 21, 2022
1 parent f43c8bd commit a36b9e7
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions pylint_django/augmentations/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -645,13 +645,18 @@ def is_model_test_case_subclass(node):
return node_is_subclass(node, "django.test.testcases.TestCase")


def generic_is_view_attribute(parents, attrs):
"""Generates is_X_attribute function for given parents and attrs."""
class IsAttribute:
def __init__(self, parents, attrs):
self.parents = parents
self.attrs = attrs

def __call__(self, node):
return _attribute_is_magic(node, self.attrs, self.parents)

def is_attribute(node):
return _attribute_is_magic(node, attrs, parents)

return is_attribute
def generic_is_view_attribute(parents, attrs) -> IsAttribute:
"""Generates is_X_attribute function for given parents and attrs."""
return IsAttribute(parents, attrs)


def is_model_view_subclass_method_shouldnt_be_function(node):
Expand Down

0 comments on commit a36b9e7

Please sign in to comment.