Beispiel #1
0
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)
Beispiel #2
0
    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)
Beispiel #3
0
    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)
Beispiel #4
0
 def visit_module(self, node):
     if is_migrations_module(node):
         self._migration_modules.append(node)