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

Generated warnings depending on arguments order #2869

Closed
robgom opened this issue Apr 16, 2019 · 2 comments
Closed

Generated warnings depending on arguments order #2869

robgom opened this issue Apr 16, 2019 · 2 comments
Labels
Duplicate 🐫 Duplicate of an already existing issue

Comments

@robgom
Copy link

robgom commented Apr 16, 2019

There's a no-member warning generated when I run pylint file1.py file2.py, but not when pylint file2.py file1.py. The warning is incorrect, I believe.

I have the following structure:

C:.
│   __init__.py
│
├───subpackage1
│       main.py
│       supplementary.py
│
└───subpackage2
        main.py
        supplementary.py

Most files are empty, the only meaningful contents is in:

c:\temp_cleared_each_night>type subpackage1\main.py
pass

c:\temp_cleared_each_night>type subpackage2\main.py
import supplementary
from unittest import TestCase

class TestClass(TestCase):
    def test_method(self):
        print("Name of the test: {}".format(supplementary.SINGLE_CONN_CONFIG_IOT))


c:\temp_cleared_each_night>type subpackage2\supplementary.py
SINGLE_CONN_CONFIG_IOT = {
}

The idea is that subpackage1 is independent from subpackage2.

Yet, when I execute:

pylint subpackage1\main.py subpackage2\main.py

I get incorrect warning:

E:  6,44: Module 'supplementary' has no 'SINGLE_CONN_CONFIG_IOT' member (no-member)

When I reverse arguments order, everything is fine:

pylint subpackage2\main.py subpackage1\main.py

The warning is invalid, because subpackage1 doesn't want to utilize this constant and doesn't have it defined. subpackage2 does want to use it (but it has it defined).
I believe that imported supplementary.py from subpackage1 is not reanalyzed in subpackage2.

I've tried to debug it in pylint and astroid, but to no avail.
I've tried to clean up astroid cache (MANAGER.clear_cache()) with no effect.

Observed on pylint 1.8, 1.9.4, Windows, Python 2.7.15.

Is there a workaround I could apply or any fix for that?

Regards,
Robert

@robgom
Copy link
Author

robgom commented Apr 19, 2019

The issue is that astroid MANAGER is singleton and it uses cached modules incorrectly.
I was able to work around the issue by using:

astroid.MANAGER._mod_file_cache.clear()
astroid.MANAGER.astroid_cache.clear()

between pylint.lint.Run(...) calls. Clearing only one of them was not enough.

Could it be done in a different way?

Regards,
Robert

@PCManticore
Copy link
Contributor

Hi @robgom Thanks for reporting the issue. We are aware of this bug, it's currently being tracked under #689. I'm closing this one as a duplicate, but feel free to subscribe to the other one for notifications.

@PCManticore PCManticore added the Duplicate 🐫 Duplicate of an already existing issue label Apr 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate 🐫 Duplicate of an already existing issue
Projects
None yet
Development

No branches or pull requests

2 participants