Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
emcd opened this issue Jan 18, 2021 · 1 comment · Fixed by #5179
Closed

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

emcd opened this issue Jan 18, 2021 · 1 comment · Fixed by #5179
Labels
Bug 🪲 False Negative 🦋 No message is emitted but something is wrong with the code
Milestone

Comments

@emcd
Copy link
Contributor

emcd commented Jan 18, 2021

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]
@hippo91
Copy link
Contributor

hippo91 commented Jan 30, 2021

@emcd thanks for the report.

@hippo91 hippo91 added Bug 🪲 False Negative 🦋 No message is emitted but something is wrong with the code labels Jan 30, 2021
@DanielNoord DanielNoord linked a pull request Oct 18, 2021 that will close this issue
4 tasks
@DanielNoord DanielNoord added this to the 2.12.0 milestone Oct 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug 🪲 False Negative 🦋 No message is emitted but something is wrong with the code
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants