|
11 | 11 | from astroid.scoped_nodes import Class as ScopedClass, Module
|
12 | 12 | from pylint.__pkginfo__ import numversion as PYLINT_VERSION
|
13 | 13 | from pylint.checkers.typecheck import TypeChecker
|
| 14 | +from pylint.checkers.variables import ScopeConsumer |
14 | 15 | from pylint_django.utils import node_is_subclass, PY3
|
15 | 16 | from pylint_django.compat import inferred
|
16 | 17 | from pylint_plugin_utils import augment_visit, suppress_message
|
@@ -280,22 +281,22 @@ def ignore_import_warnings_for_related_fields(orig_method, self, node):
|
280 | 281 | form 'from django.db.models import OneToOneField' raise an unused-import
|
281 | 282 | warning
|
282 | 283 | """
|
283 |
| - to_consume = self._to_consume[0] # pylint: disable=W0212 |
| 284 | + consumer = self._to_consume[0] # pylint: disable=W0212 |
284 | 285 | # we can disable this warning ('Access to a protected member _to_consume of a client class')
|
285 | 286 | # as it's not actually a client class, but rather, this method is being monkey patched
|
286 | 287 | # onto the class and so the access is valid
|
287 | 288 |
|
288 | 289 | new_things = {}
|
289 | 290 |
|
290 |
| - iterat = to_consume[0].items if PY3 else to_consume[0].iteritems |
| 291 | + iterat = consumer.to_consume.items if PY3 else consumer.to_consume.iteritems |
291 | 292 | for name, stmts in iterat():
|
292 | 293 | if isinstance(stmts[0], ImportFrom):
|
293 | 294 | if any([n[0] in ('ForeignKey', 'OneToOneField') for n in stmts[0].names]):
|
294 | 295 | continue
|
295 | 296 | new_things[name] = stmts
|
296 | 297 |
|
297 |
| - new_consume = (new_things,) + to_consume[1:] |
298 |
| - self._to_consume = [new_consume] # pylint: disable=W0212 |
| 298 | + consumer._atomic = ScopeConsumer(new_things, consumer.consumed, consumer.scope_type) # pylint: disable=W0212 |
| 299 | + self._to_consume = [consumer] # pylint: disable=W0212 |
299 | 300 |
|
300 | 301 | return orig_method(self, node)
|
301 | 302 |
|
|
0 commit comments