|
281 | 281 | }
|
282 | 282 |
|
283 | 283 |
|
| 284 | +FORM_ATTRS = { |
| 285 | + 'declared_fields', |
| 286 | +} |
| 287 | + |
| 288 | + |
284 | 289 | def ignore_import_warnings_for_related_fields(orig_method, self, node):
|
285 | 290 | """
|
286 | 291 | Replaces the leave_module method on the VariablesChecker class to
|
@@ -577,6 +582,12 @@ def is_onetoonefield_attribute(node):
|
577 | 582 | return _attribute_is_magic(node, ONETOONE_FIELD_ATTRS, parents)
|
578 | 583 |
|
579 | 584 |
|
| 585 | +def is_form_attribute(node): |
| 586 | + """Checks that node is attribute of Form.""" |
| 587 | + parents = ('django.forms.forms.Form', 'django.forms.models.ModelForm') |
| 588 | + return _attribute_is_magic(node, FORM_ATTRS, parents) |
| 589 | + |
| 590 | + |
580 | 591 | def is_model_test_case_subclass(node):
|
581 | 592 | """Checks that node is derivative of TestCase class."""
|
582 | 593 | if not node.name.endswith('Test') and not isinstance(node.parent, ClassDef):
|
@@ -735,6 +746,7 @@ def apply_augmentations(linter):
|
735 | 746 | suppress_message(linter, TypeChecker.visit_attribute, 'no-member', is_foreignkeyfield_attribute)
|
736 | 747 | suppress_message(linter, TypeChecker.visit_attribute, 'no-member', is_manytomanyfield_attribute)
|
737 | 748 | suppress_message(linter, TypeChecker.visit_attribute, 'no-member', is_onetoonefield_attribute)
|
| 749 | + suppress_message(linter, TypeChecker.visit_attribute, 'no-member', is_form_attribute) |
738 | 750 |
|
739 | 751 | for parents, attrs in VIEW_ATTRS:
|
740 | 752 | suppress_message(linter, TypeChecker.visit_attribute, 'no-member', generic_is_view_attribute(parents, attrs))
|
|
0 commit comments