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

False positive no-name-in-module when importing from from ccxt.base.errors even when using the ignored-modules option #8148

Closed
eabrouwer3 opened this issue Jan 31, 2023 · 6 comments · Fixed by #8169
Assignees
Labels
False Positive 🦟 A message is emitted but nothing is wrong with the code Needs PR This issue is accepted, sufficiently specified and now needs an implementation
Milestone

Comments

@eabrouwer3
Copy link

Bug description

Simply importing exceptions from the ccxt library is giving this error. Here's an example of how we import them:

from ccxt.base.errors import (
    AuthenticationError,
    ExchangeError,
    ExchangeNotAvailable,
    NetworkError,
    RateLimitExceeded,
    RequestTimeout,
)

Pycharm can find the exception classes just fine. I know they exist. It could have something to do with how the library is using __all__, but I don't know too much about how that works to draw that conclusion.

Also, note that we're using version 1.95.1 of ccxt. We use it in some critical paths, so we can't update it to the latest version quite yet.

The configuration written below is what I've tried, but it seems based on googling that that doesn't stop all errors from being ignored regarding those modules. So I'm still getting the issue.

Configuration

# List of module names for which member attributes should not be checked
# (useful for modules/projects where namespaces are manipulated during runtime
# and thus existing member attributes cannot be deduced by static analysis). It
# supports qualified module names, as well as Unix pattern matching.
ignored-modules=ccxt,ccxt.base,ccxt.base.errors

Command used

pylint test_ccxt_base_errors.py

Pylint output

************* Module test_ccxt_base_errors
test_ccxt_base_errors.py:1:0: E0611: No name 'errors' in module 'list' (no-name-in-module)

Expected behavior

No error to be reported

Pylint version

pylint 2.14.5
astroid 2.11.7
Python 3.9.16 (main, Dec  7 2022, 10:16:11)
[Clang 14.0.0 (clang-1400.0.29.202)]

OS / Environment

Intel based 2019 Mac Book Pro. Mac OS 13.1 (Ventura). Fish shell.

Additional dependencies

ccxt==1.95.1

@eabrouwer3 eabrouwer3 added the Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling label Jan 31, 2023
@Pierre-Sassoulas
Copy link
Member

Could you upgrade to at least 2.15.10 (better yet 2.16.0b1) and confirm the issue still exists, please ?

@eabrouwer3
Copy link
Author

Tried with

pylint 2.15.10
astroid 2.13.4
Python 3.9.16 (main, Dec  7 2022, 10:16:11)
[Clang 14.0.0 (clang-1400.0.29.202)]

and also with pylint 2.16.0b1 and I still get the same issue.

@Pierre-Sassoulas Pierre-Sassoulas added False Positive 🦟 A message is emitted but nothing is wrong with the code Lib specific 💅 This affect the code from a particular library Needs investigation 🔬 A bug or crash where it's not immediately obvious what is happenning and removed Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling labels Jan 31, 2023
@Pierre-Sassoulas Pierre-Sassoulas changed the title Erroneous no-name-in-module False positive no-name-in-module when importing from from ccxt.base.errors Jan 31, 2023
@Pierre-Sassoulas
Copy link
Member

Thank you ! I can reproduce, and ignored-modules does work with a simpler example like random.foo

@Pierre-Sassoulas Pierre-Sassoulas changed the title False positive no-name-in-module when importing from from ccxt.base.errors False positive no-name-in-module when importing from from ccxt.base.errors even when using the ignored-modules option Jan 31, 2023
@clavedeluna
Copy link
Collaborator

@Pierre-Sassoulas is the fix here:

  1. figure out why the ccxt library causes a no-name-in-module msg
  2. figure out why using ignored-modules is still raising no-name-in-module
    ?

@Pierre-Sassoulas
Copy link
Member

Yes, I think 2/ is the one to prioritize as it's going to be useful for everyone and not just ccxt users. But if we manage find the root cause of 1/ it's going to be generic too.

@clavedeluna
Copy link
Collaborator

There is a non-ccxt root cause. This issue can be reproduced with the following dir structure:

pkg_mod_imports/__init__.py
pkg_mod_imports/base/__init__.py
pkg_mod_imports/base/errors.py

pkg_mod_imports/init.py should have :

base = [
    'Exchange',
    'Precise',
    'exchanges',
    'decimal_to_precision',
]

and pkg_mod_imports/base/errors.py

class SomeError(Exception):
    pass

in a test.py module add

from pkg_mod_imports.base.errors import SomeError

And then running pylint test.py the result is

test.py:1:0: E0611: No name 'errors' in module 'list' (no-name-in-module)

It's coming from the fact that errors is both a list inside the init file and the name of a module. variable.py does module = next(module.getattr(name)[0].infer()) . getattr fetches the errors list, not the module!

@clavedeluna clavedeluna self-assigned this Feb 1, 2023
@clavedeluna clavedeluna added Needs PR This issue is accepted, sufficiently specified and now needs an implementation and removed Needs investigation 🔬 A bug or crash where it's not immediately obvious what is happenning Lib specific 💅 This affect the code from a particular library labels Feb 1, 2023
@Pierre-Sassoulas Pierre-Sassoulas added this to the 2.16.2 milestone Feb 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
False Positive 🦟 A message is emitted but nothing is wrong with the code Needs PR This issue is accepted, sufficiently specified and now needs an implementation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants