Skip to content

Commit 29232de

Browse files
committed
augmentation: use ScopeConsumer instead an array
pylint-dev/pylint@d343169 had introduced NamesConsumerAtomic (renamed in ScopeConsumer in pylint-dev/pylint@b80d76d). ref pylint-dev/pylint@d343169 ref codacy/codacy-pylint#29 fix pylint-dev#120
1 parent 68ef4b5 commit 29232de

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

pylint_django/augmentations/__init__.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from astroid.scoped_nodes import Class as ScopedClass, Module
1212
from pylint.__pkginfo__ import numversion as PYLINT_VERSION
1313
from pylint.checkers.typecheck import TypeChecker
14+
from pylint.checkers.variables import ScopeConsumer
1415
from pylint_django.utils import node_is_subclass, PY3
1516
from pylint_django.compat import inferred
1617
from pylint_plugin_utils import augment_visit, suppress_message
@@ -280,22 +281,22 @@ def ignore_import_warnings_for_related_fields(orig_method, self, node):
280281
form 'from django.db.models import OneToOneField' raise an unused-import
281282
warning
282283
"""
283-
to_consume = self._to_consume[0] # pylint: disable=W0212
284+
consumer = self._to_consume[0] # pylint: disable=W0212
284285
# we can disable this warning ('Access to a protected member _to_consume of a client class')
285286
# as it's not actually a client class, but rather, this method is being monkey patched
286287
# onto the class and so the access is valid
287288

288289
new_things = {}
289290

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
291292
for name, stmts in iterat():
292293
if isinstance(stmts[0], ImportFrom):
293294
if any([n[0] in ('ForeignKey', 'OneToOneField') for n in stmts[0].names]):
294295
continue
295296
new_things[name] = stmts
296297

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
299300

300301
return orig_method(self, node)
301302

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333

3434
_install_requires = [
3535
'pylint-plugin-utils>=0.2.1',
36-
'pylint>=1.8'
36+
'pylint>=1.8.2'
3737
]
3838

3939

0 commit comments

Comments
 (0)