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

Replace no-method-argument with no-self-argument when variadic args present #7518

Merged
merged 5 commits into from
Sep 23, 2022
Merged

Conversation

Jackenmen
Copy link
Contributor

Type of Changes

Type
🐛 Bug fix

Description

Report no-self-argument rather than no-method-argument for methods with variadic arguments.
Per the comment in #7507, I also added method name to the error messages of no-method-argument and no-self-argument

Closes #7507

@coveralls
Copy link

coveralls commented Sep 23, 2022

Pull Request Test Coverage Report for Build 3113264052

  • 3 of 3 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 95.315%

Totals Coverage Status
Change from base Build 3108882423: 0.0%
Covered Lines: 17109
Relevant Lines: 17950

💛 - Coveralls

doc/whatsnew/fragments/7507.bugfix Outdated Show resolved Hide resolved
doc/whatsnew/fragments/7507.other Outdated Show resolved Hide resolved
pylint/checkers/classes/class_checker.py Outdated Show resolved Hide resolved
@github-actions
Copy link
Contributor

🤖 Effect of this PR on checked open source code: 🤖

Effect on django:
The following messages are now emitted:

  1. no-self-argument:
    Method 'live_server_url' should have "self" as first argument
    https://github.com/django/django/blob/37a13cc92d51d5a57b42240b9a5dd250648efa24/django/test/selenium.py#L105
  2. no-self-argument:
    Method 'allowed_host' should have "self" as first argument
    https://github.com/django/django/blob/37a13cc92d51d5a57b42240b9a5dd250648efa24/django/test/selenium.py#L109
  3. no-self-argument:
    Method 'log_message' should have "self" as first argument
    https://github.com/django/django/blob/37a13cc92d51d5a57b42240b9a5dd250648efa24/django/test/testcases.py#L1657
  4. no-self-argument:
    Method 'live_server_url' should have "self" as first argument
    https://github.com/django/django/blob/37a13cc92d51d5a57b42240b9a5dd250648efa24/django/test/testcases.py#L1810
  5. no-self-argument:
    Method 'allowed_host' should have "self" as first argument
    https://github.com/django/django/blob/37a13cc92d51d5a57b42240b9a5dd250648efa24/django/test/testcases.py#L1814
  6. no-self-argument:
    Method 'view_is_async' should have "self" as first argument
    https://github.com/django/django/blob/37a13cc92d51d5a57b42240b9a5dd250648efa24/django/views/generic/base.py#L63
  7. no-self-argument:
    Method '_router_func' should have "self" as first argument
    https://github.com/django/django/blob/37a13cc92d51d5a57b42240b9a5dd250648efa24/django/db/utils.py#L217
  8. no-self-argument:
    Method 'Migration' should have "self" as first argument
    https://github.com/django/django/blob/37a13cc92d51d5a57b42240b9a5dd250648efa24/django/db/migrations/recorder.py#L25
  9. no-self-argument:
    Method 'generate_next_value' should have "self" as first argument
    https://github.com/django/django/blob/37a13cc92d51d5a57b42240b9a5dd250648efa24/django/db/models/enums.py#L91

The following messages are no longer emitted:

  1. no-self-argument:
    Method should have "self" as first argument
    https://github.com/django/django/blob/37a13cc92d51d5a57b42240b9a5dd250648efa24/django/test/selenium.py#L105
  2. no-self-argument:
    Method should have "self" as first argument
    https://github.com/django/django/blob/37a13cc92d51d5a57b42240b9a5dd250648efa24/django/test/selenium.py#L109
  3. no-method-argument:
    Method has no argument
    https://github.com/django/django/blob/37a13cc92d51d5a57b42240b9a5dd250648efa24/django/test/testcases.py#L1657
  4. no-self-argument:
    Method should have "self" as first argument
    https://github.com/django/django/blob/37a13cc92d51d5a57b42240b9a5dd250648efa24/django/test/testcases.py#L1810
  5. no-self-argument:
    Method should have "self" as first argument
    https://github.com/django/django/blob/37a13cc92d51d5a57b42240b9a5dd250648efa24/django/test/testcases.py#L1814
  6. no-self-argument:
    Method should have "self" as first argument
    https://github.com/django/django/blob/37a13cc92d51d5a57b42240b9a5dd250648efa24/django/views/generic/base.py#L63
  7. no-self-argument:
    Method should have "self" as first argument
    https://github.com/django/django/blob/37a13cc92d51d5a57b42240b9a5dd250648efa24/django/db/utils.py#L217
  8. no-self-argument:
    Method should have "self" as first argument
    https://github.com/django/django/blob/37a13cc92d51d5a57b42240b9a5dd250648efa24/django/db/migrations/recorder.py#L25
  9. no-self-argument:
    Method should have "self" as first argument
    https://github.com/django/django/blob/37a13cc92d51d5a57b42240b9a5dd250648efa24/django/db/models/enums.py#L91

Effect on pandas:
The following messages are now emitted:

  1. no-self-argument:
    Method '_from_sequence' should have "self" as first argument
    https://github.com/pandas-dev/pandas/blob/cda0f6bee2a6520729247f92eef9f722ad2487ec/pandas/tests/extension/decimal/test_decimal.py#L287
  2. no-self-argument:
    Method '_period_constructor' should have "self" as first argument
    https://github.com/pandas-dev/pandas/blob/cda0f6bee2a6520729247f92eef9f722ad2487ec/pandas/tests/scalar/period/test_period.py#L843
  3. no-self-argument:
    Method 'open' should have "self" as first argument
    https://github.com/pandas-dev/pandas/blob/cda0f6bee2a6520729247f92eef9f722ad2487ec/pandas/tests/io/test_gcs.py#L36
  4. no-self-argument:
    Method 'setup_class' should have "self" as first argument
    https://github.com/pandas-dev/pandas/blob/cda0f6bee2a6520729247f92eef9f722ad2487ec/pandas/tests/io/test_sql.py#L1609

The following messages are no longer emitted:

  1. no-self-argument:
    Method should have "self" as first argument
    https://github.com/pandas-dev/pandas/blob/cda0f6bee2a6520729247f92eef9f722ad2487ec/pandas/tests/extension/decimal/test_decimal.py#L287
  2. no-self-argument:
    Method should have "self" as first argument
    https://github.com/pandas-dev/pandas/blob/cda0f6bee2a6520729247f92eef9f722ad2487ec/pandas/tests/scalar/period/test_period.py#L843
  3. no-method-argument:
    Method has no argument
    https://github.com/pandas-dev/pandas/blob/cda0f6bee2a6520729247f92eef9f722ad2487ec/pandas/tests/io/test_gcs.py#L36
  4. no-self-argument:
    Method should have "self" as first argument
    https://github.com/pandas-dev/pandas/blob/cda0f6bee2a6520729247f92eef9f722ad2487ec/pandas/tests/io/test_sql.py#L1609

Effect on pytest:
The following messages are now emitted:

  1. no-self-argument:
    Method 'pytest_configure' should have "self" as first argument
    https://github.com/pytest-dev/pytest/blob/59b8ec3ce11f8e94d924dc97bc1e14f380824b54/src/_pytest/pytester.py#L1131

The following messages are no longer emitted:

  1. no-self-argument:
    Method should have "self" as first argument
    https://github.com/pytest-dev/pytest/blob/59b8ec3ce11f8e94d924dc97bc1e14f380824b54/src/_pytest/pytester.py#L1131

Effect on sentry:
The following messages are now emitted:

  1. no-self-argument:
    Method 'merge_to' should have "self" as first argument
    https://github.com/getsentry/sentry/blob/48eb9791a9561abf2bad91f25d48950731feaf09/src/sentry/models/user.py#L300
  2. no-self-argument:
    Method 'merge_to' should have "self" as first argument
    https://github.com/getsentry/sentry/blob/48eb9791a9561abf2bad91f25d48950731feaf09/src/sentry/models/organization.py#L285
  3. no-self-argument:
    Method 'path' should have "self" as first argument
    https://github.com/getsentry/sentry/blob/48eb9791a9561abf2bad91f25d48950731feaf09/src/sentry/interfaces/base.py#L80
  4. no-self-argument:
    Method 'external_type' should have "self" as first argument
    https://github.com/getsentry/sentry/blob/48eb9791a9561abf2bad91f25d48950731feaf09/src/sentry/interfaces/base.py#L85
  5. no-self-argument:
    Method 'is_available' should have "self" as first argument
    https://github.com/getsentry/sentry/blob/48eb9791a9561abf2bad91f25d48950731feaf09/src/sentry/auth/authenticators/sms.py#L39
  6. no-self-argument:
    Method 'u2f_app_id' should have "self" as first argument
    https://github.com/getsentry/sentry/blob/48eb9791a9561abf2bad91f25d48950731feaf09/src/sentry/auth/authenticators/u2f.py#L65
  7. no-self-argument:
    Method 'u2f_facets' should have "self" as first argument
    https://github.com/getsentry/sentry/blob/48eb9791a9561abf2bad91f25d48950731feaf09/src/sentry/auth/authenticators/u2f.py#L70
  8. no-self-argument:
    Method 'is_available' should have "self" as first argument
    https://github.com/getsentry/sentry/blob/48eb9791a9561abf2bad91f25d48950731feaf09/src/sentry/auth/authenticators/u2f.py#L77
  9. no-self-argument:
    Method 'rate_limits' should have "self" as first argument
    https://github.com/getsentry/sentry/blob/48eb9791a9561abf2bad91f25d48950731feaf09/src/sentry/api/endpoints/organization_events.py#L108
  10. no-self-argument:
    Method 'use_email_scope' should have "self" as first argument
    https://github.com/getsentry/sentry/blob/48eb9791a9561abf2bad91f25d48950731feaf09/src/sentry/integrations/jira_server/integration.py#L277
  11. no-self-argument:
    Method 'use_email_scope' should have "self" as first argument
    https://github.com/getsentry/sentry/blob/48eb9791a9561abf2bad91f25d48950731feaf09/src/sentry/integrations/jira/integration.py#L126

The following messages are no longer emitted:

  1. no-self-argument:
    Method should have "self" as first argument
    https://github.com/getsentry/sentry/blob/48eb9791a9561abf2bad91f25d48950731feaf09/src/sentry/models/user.py#L300
  2. no-self-argument:
    Method should have "self" as first argument
    https://github.com/getsentry/sentry/blob/48eb9791a9561abf2bad91f25d48950731feaf09/src/sentry/models/organization.py#L285
  3. no-self-argument:
    Method should have "self" as first argument
    https://github.com/getsentry/sentry/blob/48eb9791a9561abf2bad91f25d48950731feaf09/src/sentry/interfaces/base.py#L80
  4. no-self-argument:
    Method should have "self" as first argument
    https://github.com/getsentry/sentry/blob/48eb9791a9561abf2bad91f25d48950731feaf09/src/sentry/interfaces/base.py#L85
  5. no-self-argument:
    Method should have "self" as first argument
    https://github.com/getsentry/sentry/blob/48eb9791a9561abf2bad91f25d48950731feaf09/src/sentry/auth/authenticators/sms.py#L39
  6. no-self-argument:
    Method should have "self" as first argument
    https://github.com/getsentry/sentry/blob/48eb9791a9561abf2bad91f25d48950731feaf09/src/sentry/auth/authenticators/u2f.py#L65
  7. no-self-argument:
    Method should have "self" as first argument
    https://github.com/getsentry/sentry/blob/48eb9791a9561abf2bad91f25d48950731feaf09/src/sentry/auth/authenticators/u2f.py#L70
  8. no-self-argument:
    Method should have "self" as first argument
    https://github.com/getsentry/sentry/blob/48eb9791a9561abf2bad91f25d48950731feaf09/src/sentry/auth/authenticators/u2f.py#L77
  9. no-method-argument:
    Method has no argument
    https://github.com/getsentry/sentry/blob/48eb9791a9561abf2bad91f25d48950731feaf09/src/sentry/api/endpoints/organization_events.py#L108
  10. no-self-argument:
    Method should have "self" as first argument
    https://github.com/getsentry/sentry/blob/48eb9791a9561abf2bad91f25d48950731feaf09/src/sentry/integrations/jira_server/integration.py#L277
  11. no-self-argument:
    Method should have "self" as first argument
    https://github.com/getsentry/sentry/blob/48eb9791a9561abf2bad91f25d48950731feaf09/src/sentry/integrations/jira/integration.py#L126

This comment was generated for commit 7e86289

@Pierre-Sassoulas Pierre-Sassoulas added Bug 🪲 Needs backport Needs to be cherry-picked on the current patch version by a pylint's maintainer labels Sep 23, 2022
@Pierre-Sassoulas Pierre-Sassoulas added this to the 2.15.4 milestone Sep 23, 2022
Copy link
Member

@Pierre-Sassoulas Pierre-Sassoulas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM thank you. Better message in general, and a nice fix to a nonsensical message 👌

@Pierre-Sassoulas Pierre-Sassoulas merged commit b418a7f into pylint-dev:main Sep 23, 2022
@Jackenmen Jackenmen deleted the issue_7507 branch September 23, 2022 19:52
Pierre-Sassoulas pushed a commit to Pierre-Sassoulas/pylint that referenced this pull request Oct 9, 2022
@Pierre-Sassoulas Pierre-Sassoulas added Backported and removed Needs backport Needs to be cherry-picked on the current patch version by a pylint's maintainer labels Oct 9, 2022
Pierre-Sassoulas pushed a commit to Pierre-Sassoulas/pylint that referenced this pull request Oct 10, 2022
Pierre-Sassoulas pushed a commit that referenced this pull request Oct 10, 2022
…resent (#7518)

Also add method name to the error message
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Method with variadic args/kwargs but no self reports no-method-argument instead of no-self-argument
4 participants