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

Proper use of generated-members= setting #2498

Closed
gpakosz opened this issue Sep 19, 2018 · 5 comments · Fixed by #4092
Closed

Proper use of generated-members= setting #2498

gpakosz opened this issue Sep 19, 2018 · 5 comments · Fixed by #4092
Assignees
Labels
Bug 🪲 False Negative 🦋 No message is emitted but something is wrong with the code

Comments

@gpakosz
Copy link

gpakosz commented Sep 19, 2018

Question

Hello, I'm using the Google Drive Python API and the following snippet generates E1101:

    # Call the Drive v3 API
    results = service.files().list(
        pageSize=10, fields="nextPageToken, files(id, name)").execute()
    items = results.get('files', [])
E1101: Instance of 'Resource' has no 'files' member (no-member)

What's the proper way to silence these E1101?
I tried this in my .pylintrc without success:

generated-members=googleapiclient\.discovery\.Resource\..*

And trying a broader match doesn't help either:

generated-members=googleapiclient.*
@PCManticore
Copy link
Contributor

@gpakosz googleapiclient.discovery.Resource.* should have worked but I think this is currently not working correctly because there is a bug with the applied regular expressions in pylint. It currently matches either against the attribute name (so in this case files) or against the string representation of the object that gets called (and for some reason that is service.files()), but it should match against the qualified name instead.

@bgaillard
Copy link

Any news about this problem ?

I can confirm what @PCManticore mentioned, but in our case we have a Pylint configuration file used accross several projets / components and we cannot add all the generated members (the list would be huge).

@twilson90
Copy link

Same issue. Nothing I've tried works.
generated-members=googleapiclient.discovery.Resource.* should work but it doesn't suppress any linting errors.

zeronounours pushed a commit to zeronounours/pylint that referenced this issue May 17, 2020
zeronounours pushed a commit to zeronounours/pylint that referenced this issue May 17, 2020
sgrimm added a commit to sgrimm/rhizo-server that referenced this issue Nov 14, 2020
Introduce pylint to do deeper analysis of the code than flake8 supports.
Currently, only errors and warnings are enabled (not suggested refactoring and
convention violations), and this change fixes the code so that pylint passes.

The fixes fall into a few categories:

* Renaming variables to avoid conflicts with built-in function names. This was by
  far the biggest category of warnings. This doesn't affect class field names so
  should have no impact on SQLAlchemy. The frequent offenders were `id`, `type`,
  `filter`, and `zip`.
* Logging calls that formatted messages with the `%` operator; these now pass the
  format arguments to the logging functions.
* Implicit int conversion of SQLAlchemy numeric column objects. These work but
  pylint doesn't know about them, so they now have explicit `int()` wrappers.

Thanks to limitations/bugs in pylint, there were some errors that weren't possible
to clean up by changing the code, so they're disabled here:

* `no-member` is the big one: pylint complains about all the dynamically-created
  functions on SQLAlchemy objects (e.g., the `filter` method on queries) and the
  config option that's supposed to let you manually tell it which names get added
  to which classes is broken right now: pylint-dev/pylint#2498
* Unused argument checking is disabled for functions that are passed as callbacks
  to libraries.
* In the test code, we need to set environment variables before importing Flask
  modules with side effects, so the "all imports have to be at the top of the
  module" check is disabled there.
* pytest doesn't let you define test classes with initializer functions, so the
  "attribute defined outside initializer" check is disabled there.
sgrimm added a commit to sgrimm/rhizo-server that referenced this issue Nov 14, 2020
Introduce pylint to do deeper analysis of the code than flake8 supports.
Currently, only errors and warnings are enabled (not suggested refactoring and
convention violations), and this change fixes the code so that pylint passes.

The fixes fall into a few categories:

* Renaming variables to avoid conflicts with built-in function names. This was by
  far the biggest category of warnings. This doesn't affect class field names so
  should have no impact on SQLAlchemy. The frequent offenders were `id`, `type`,
  `filter`, and `zip`.
* Logging calls that formatted messages with the `%` operator; these now pass the
  format arguments to the logging functions.
* Implicit int conversion of SQLAlchemy numeric column objects. These work but
  pylint doesn't know about them, so they now have explicit `int()` wrappers.

Thanks to limitations/bugs in pylint, there were some errors that weren't possible
to clean up by changing the code, so they're disabled here:

* `no-member` is the big one: pylint complains about all the dynamically-created
  functions on SQLAlchemy objects (e.g., the `filter` method on queries) and the
  config option that's supposed to let you manually tell it which names get added
  to which classes is broken right now: pylint-dev/pylint#2498
* Unused argument checking is disabled for functions that are passed as callbacks
  to libraries.
* In the test code, we need to set environment variables before importing Flask
  modules with side effects, so the "all imports have to be at the top of the
  module" check is disabled there.
* pytest doesn't let you define test classes with initializer functions, so the
  "attribute defined outside initializer" check is disabled there.
sgrimm added a commit to sgrimm/rhizo-server that referenced this issue Nov 14, 2020
Introduce pylint to do deeper analysis of the code than flake8 supports.
Currently, only errors and warnings are enabled (not suggested refactoring and
convention violations), and this change fixes the code so that pylint passes.

The fixes fall into a few categories:

* Renaming variables to avoid conflicts with built-in function names. This was by
  far the biggest category of warnings. This doesn't affect class field names so
  should have no impact on SQLAlchemy. The frequent offenders were `id`, `type`,
  `filter`, and `zip`.
* Logging calls that formatted messages with the `%` operator; these now pass the
  format arguments to the logging functions.
* Implicit int conversion of SQLAlchemy numeric column objects. These work but
  pylint doesn't know about them, so they now have explicit `int()` wrappers.

Thanks to limitations/bugs in pylint, there were some errors that weren't possible
to clean up by changing the code, so they're disabled here:

* `no-member` is the big one: pylint complains about all the dynamically-created
  functions on SQLAlchemy objects (e.g., the `filter` method on queries) and the
  config option that's supposed to let you manually tell it which names get added
  to which classes is broken right now: pylint-dev/pylint#2498
* Unused argument checking is disabled for functions that are passed as callbacks
  to libraries.
* In the test code, we need to set environment variables before importing Flask
  modules with side effects, so the "all imports have to be at the top of the
  module" check is disabled there.
* pytest doesn't let you define test classes with initializer functions, so the
  "attribute defined outside initializer" check is disabled there.
@scorpp
Copy link

scorpp commented Dec 23, 2020

any updates?

@hippo91
Copy link
Contributor

hippo91 commented Dec 29, 2020

@scorpp the issue is still open, but there is the PR #3634 that may solve it.

@hippo91 hippo91 self-assigned this Dec 29, 2020
graingert pushed a commit to graingert/pylint that referenced this issue Jan 22, 2021
graingert pushed a commit to graingert/pylint that referenced this issue Jan 27, 2021
Pierre-Sassoulas pushed a commit to Pierre-Sassoulas/pylint that referenced this issue Feb 15, 2021
@Pierre-Sassoulas Pierre-Sassoulas added the False Negative 🦋 No message is emitted but something is wrong with the code label Feb 15, 2021
Pierre-Sassoulas added a commit that referenced this issue Feb 15, 2021
* Fix #2498: add generated-members match against the qualified name

Add test for fully qualified generated-members

Co-authored-by: Gauthier Sebaux <gauthier.sebaux@wavestone.com>
Co-authored-by: Thomas Grainger <tagrain@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment