pylint-dev / pylint

It's not just a linter that annoys you!
https://pylint.readthedocs.io/en/latest/
GNU General Public License v2.0
5.32k stars 1.14k forks source link

E1101 on tensorflow.variable_scope() #1412

Closed petrux closed 1 year ago

petrux commented 7 years ago

Steps to reproduce

  1. just run pylint on the following python snippet:
    import tensorflow as tf
    next(tf.variable_scope('MyScope').gen)

Current behavior

For short, the error is E: 2, 5: Generator 'generator' has no 'gen' member (no-member).
Here follows the full pylint output.

petrux@machine:~$ cat scratch.py 
import tensorflow as tf
next(tf.variable_scope('MyScope').gen)

petrux@machine:~$ pylint scratch.py 
No config file found, using default configuration
************* Module liteflow.scratch
C:  1, 0: Missing module docstring (missing-docstring)
E:  2, 5: Generator 'generator' has no 'gen' member (no-member)

Report
======
2 statements analysed.

Statistics by type
------------------

+---------+-------+-----------+-----------+------------+---------+
|type     |number |old number |difference |%documented |%badname |
+=========+=======+===========+===========+============+=========+
|module   |1      |1          |=          |0.00        |0.00     |
+---------+-------+-----------+-----------+------------+---------+
|class    |0      |0          |=          |0           |0        |
+---------+-------+-----------+-----------+------------+---------+
|method   |0      |0          |=          |0           |0        |
+---------+-------+-----------+-----------+------------+---------+
|function |0      |0          |=          |0           |0        |
+---------+-------+-----------+-----------+------------+---------+

External dependencies
---------------------
::

    tensorflow (liteflow.scratch)

Raw metrics
-----------

+----------+-------+------+---------+-----------+
|type      |number |%     |previous |difference |
+==========+=======+======+=========+===========+
|code      |2      |66.67 |NC       |NC         |
+----------+-------+------+---------+-----------+
|docstring |0      |0.00  |NC       |NC         |
+----------+-------+------+---------+-----------+
|comment   |0      |0.00  |NC       |NC         |
+----------+-------+------+---------+-----------+
|empty     |1      |33.33 |NC       |NC         |
+----------+-------+------+---------+-----------+

Duplication
-----------

+-------------------------+------+---------+-----------+
|                         |now   |previous |difference |
+=========================+======+=========+===========+
|nb duplicated lines      |0     |0        |=          |
+-------------------------+------+---------+-----------+
|percent duplicated lines |0.000 |0.000    |=          |
+-------------------------+------+---------+-----------+

Messages by category
--------------------

+-----------+-------+---------+-----------+
|type       |number |previous |difference |
+===========+=======+=========+===========+
|convention |1      |1        |=          |
+-----------+-------+---------+-----------+
|refactor   |0      |0        |=          |
+-----------+-------+---------+-----------+
|warning    |0      |0        |=          |
+-----------+-------+---------+-----------+
|error      |1      |1        |=          |
+-----------+-------+---------+-----------+

Messages
--------

+------------------+------------+
|message id        |occurrences |
+==================+============+
|no-member         |1           |
+------------------+------------+
|missing-docstring |1           |
+------------------+------------+

Global evaluation
-----------------
Your code has been rated at -20.00/10

Expected behavior

No error.

pylint --version output

petrux@machine:~$ which pylint
/usr/bin/pylint

petrux@machine:~$ pylint --version
No config file found, using default configuration
pylint 1.5.2, 
astroid 1.4.4
Python 2.7.12 (default, Nov 19 2016, 06:48:10) 
[GCC 5.4.0 20160609]

petrux@machine:~$ which python
/usr/bin/python

petrux@machine:~$ ls -la /usr/bin/python
lrwxrwxrwx 1 root root 9 dic 10  2015 /usr/bin/python -> python2.7
PCManticore commented 7 years ago

Thank you for submitting an issue. Can you check with latest pylint (1.6.5, astroid 1.4.9) and let me know if it still reproduces?

petrux commented 7 years ago

Apparently, yes:

petrux@orion:~$ pylint --version
No config file found, using default configuration
pylint 1.6.5, 
astroid 1.4.9
Python 2.7.12 (default, Nov 19 2016, 06:48:10) 
[GCC 5.4.0 20160609]

petrux@orion:~$ cat test.py 
import tensorflow as tf
next(tf.variable_scope('MyScope').gen)

petrux@orion:~$ pylint test.py 
No config file found, using default configuration
************* Module test
C:  1, 0: Missing module docstring (missing-docstring)
E:  2, 5: Generator 'generator' has no 'gen' member (no-member)

Report
======
2 statements analysed.

Statistics by type
------------------

+---------+-------+-----------+-----------+------------+---------+
|type     |number |old number |difference |%documented |%badname |
+=========+=======+===========+===========+============+=========+
|module   |1      |1          |=          |0.00        |0.00     |
+---------+-------+-----------+-----------+------------+---------+
|class    |0      |0          |=          |0           |0        |
+---------+-------+-----------+-----------+------------+---------+
|method   |0      |0          |=          |0           |0        |
+---------+-------+-----------+-----------+------------+---------+
|function |0      |0          |=          |0           |0        |
+---------+-------+-----------+-----------+------------+---------+

External dependencies
---------------------
::

    tensorflow (test)

Raw metrics
-----------

+----------+-------+------+---------+-----------+
|type      |number |%     |previous |difference |
+==========+=======+======+=========+===========+
|code      |2      |66.67 |2        |=          |
+----------+-------+------+---------+-----------+
|docstring |0      |0.00  |0        |=          |
+----------+-------+------+---------+-----------+
|comment   |0      |0.00  |0        |=          |
+----------+-------+------+---------+-----------+
|empty     |1      |33.33 |1        |=          |
+----------+-------+------+---------+-----------+

Duplication
-----------

+-------------------------+------+---------+-----------+
|                         |now   |previous |difference |
+=========================+======+=========+===========+
|nb duplicated lines      |0     |0        |=          |
+-------------------------+------+---------+-----------+
|percent duplicated lines |0.000 |0.000    |=          |
+-------------------------+------+---------+-----------+

Messages by category
--------------------

+-----------+-------+---------+-----------+
|type       |number |previous |difference |
+===========+=======+=========+===========+
|convention |1      |1        |=          |
+-----------+-------+---------+-----------+
|refactor   |0      |0        |=          |
+-----------+-------+---------+-----------+
|warning    |0      |0        |=          |
+-----------+-------+---------+-----------+
|error      |1      |1        |=          |
+-----------+-------+---------+-----------+

Messages
--------

+------------------+------------+
|message id        |occurrences |
+==================+============+
|no-member         |1           |
+------------------+------------+
|missing-docstring |1           |
+------------------+------------+

Global evaluation
-----------------
Your code has been rated at -20.00/10 (previous run: -20.00/10, +0.00)
eugeeeeene commented 1 year ago

@petrux Hello, I'm having the same problem with the code as you in this project file: https://github.com/dkmfbk/dket May I ask you to tell me how you solved this problem?

Pierre-Sassoulas commented 1 year ago

There's a number of way to fix this see the documentation for no-member: https://pylint.pycqa.org/en/latest/user_guide/messages/error/no-member.html.

I'm going to close because this kind of thing should be handled in a pylint-tensorflow plugin or can be alleviated with configuration. And this is unlikely to be ever fixed in pylint.