Skip to content

Undefined values to class keyword arguments (including metaclass) not caught. #4031

@emcd

Description

@emcd

Almost certainly related to #4021 - most likely all class keywords arguments are not being checked.

Reproducer:

class Something( metaclass = ClassFactory ): pass
class ClassFactory( type ): pass

Steps to reproduce

  1. Run pylint --score=no --reports=no --enable=all --disable=missing-module-docstring,missing-class-docstring,multiple-statements,too-few-public-methods,multiple-statements on the reproducer above.
  2. Note the lack of complaint about using ClassFactory being undefined.
  3. Run the reproducer in a Python interpreter and note that it chokes on the undefined variable.
$ pylint --score=no --reports=no --enable=all --disable=missing-module-docstring,missing-class-docstring,multiple-statements,too-few-public-methods,multiple-statements pylint-bugs/metaclass_definition_order.py
$ echo $?
0
$ python3 pylint-bugs/metaclass_definition_order.py 
Traceback (most recent call last):
  File "pylint-bugs/metaclass_definition_order.py", line 1, in <module>
    class Something( metaclass = ClassFactory ): pass
NameError: name 'ClassFactory' is not defined

Current behavior

No error from Pylint.

Expected behavior

An error about attempting to use an undefined variable in a class keyword.

pylint --version output

$ pylint --version
pylint 2.6.0
astroid 2.4.2
Python 3.6.12 (default, Nov  8 2020, 15:40:05) 
[GCC 5.4.0 20160609]

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bug 🪲False Negative 🦋No message is emitted but something is wrong with the code

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions