def is_in_migrations(node): """ RunPython() migrations receive forward/backwards functions with signature: def func(apps, schema_editor): which could be unused. This augmentation will suppress all 'unused-argument' messages coming from functions in migration modules. """ return is_migrations_module(node.parent)
def visit_call(self, node): try: module = node.frame().parent except: # noqa: E722, pylint: disable=bare-except return if not is_migrations_module(module): return if _is_addfield_with_default(node): if module not in self._possible_offences: self._possible_offences[module] = [] if node not in self._possible_offences[module]: self._possible_offences[module].append(node)
def visit_call(self, node): try: module = node.frame().parent except: # noqa: E722, pylint: disable=bare-except return if not is_migrations_module(module): return if node.func.as_string().endswith('RunPython') and len(node.args) < 2: if node.keywords: for keyword in node.keywords: if keyword.arg == 'reverse_code': return self.add_message('missing-backwards-migration-callable', node=node) else: self.add_message('missing-backwards-migration-callable', node=node)
def visit_module(self, node): if is_migrations_module(node): self._migration_modules.append(node)