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

Emit using-constant-test when testing truth value of a call returning a generator #6911

Merged
merged 4 commits into from
Jun 11, 2022

Conversation

jacobtylerwalls
Copy link
Member

Type of Changes

Type
✨ New feature

Description

We already emitted a message for testing a generator directly, just not calls to functions that only return generators.

Also update confidence level.

Closes #6909

…ng a generator

Update confidence level to INFERENCE for `using-constant-test` and `missing-parentheses-for-call-in-test`
@jacobtylerwalls jacobtylerwalls added the Enhancement ✨ Improvement to a component label Jun 10, 2022
@jacobtylerwalls jacobtylerwalls added this to the 2.15.0 milestone Jun 10, 2022
@coveralls
Copy link

coveralls commented Jun 10, 2022

Pull Request Test Coverage Report for Build 2480028583

  • 13 of 13 (100.0%) changed or added relevant lines in 1 file are covered.
  • 28 unchanged lines in 2 files lost coverage.
  • Overall coverage decreased (-0.004%) to 95.522%

Files with Coverage Reduction New Missed Lines %
pylint/checkers/refactoring/refactoring_checker.py 3 98.19%
pylint/checkers/variables.py 25 96.61%
Totals Coverage Status
Change from base Build 2475449403: -0.004%
Covered Lines: 16382
Relevant Lines: 17150

💛 - Coveralls

@github-actions

This comment has been minimized.

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.

Looks pretty good already !

pylint/checkers/base/basic_checker.py Outdated Show resolved Hide resolved
@github-actions

This comment has been minimized.

@github-actions
Copy link
Contributor

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

Effect on sentry:
The following messages are now emitted:

  1. consider-using-f-string:
    Formatting a regular string which could be a f-string
    https://github.com/getsentry/sentry/blob/master/src/sentry/audit_log/events.py#L51
  2. consider-using-f-string:
    Formatting a regular string which could be a f-string
    https://github.com/getsentry/sentry/blob/master/src/sentry/audit_log/events.py#L56
  3. too-few-public-methods:
    Too few public methods (1/2)
    https://github.com/getsentry/sentry/blob/master/src/sentry/audit_log/events.py#L45
  4. missing-class-docstring:
    Missing class docstring
    https://github.com/getsentry/sentry/blob/master/src/sentry/audit_log/events.py#L59
  5. consider-using-f-string:
    Formatting a regular string which could be a f-string
    https://github.com/getsentry/sentry/blob/master/src/sentry/audit_log/events.py#L65
  6. consider-using-f-string:
    Formatting a regular string which could be a f-string
    https://github.com/getsentry/sentry/blob/master/src/sentry/audit_log/events.py#L70
  7. too-few-public-methods:
    Too few public methods (1/2)
    https://github.com/getsentry/sentry/blob/master/src/sentry/audit_log/events.py#L59
  8. missing-class-docstring:
    Missing class docstring
    https://github.com/getsentry/sentry/blob/master/src/sentry/audit_log/events.py#L73
  9. too-few-public-methods:
    Too few public methods (1/2)
    https://github.com/getsentry/sentry/blob/master/src/sentry/audit_log/events.py#L73
  10. missing-class-docstring:
    Missing class docstring
    https://github.com/getsentry/sentry/blob/master/src/sentry/audit_log/events.py#L84
  11. too-few-public-methods:
    Too few public methods (1/2)
    https://github.com/getsentry/sentry/blob/master/src/sentry/audit_log/events.py#L84
  12. missing-class-docstring:
    Missing class docstring
    https://github.com/getsentry/sentry/blob/master/src/sentry/audit_log/events.py#L93
  13. consider-using-f-string:
    Formatting a regular string which could be a f-string
    https://github.com/getsentry/sentry/blob/master/src/sentry/audit_log/events.py#L99
  14. too-few-public-methods:
    Too few public methods (1/2)
    https://github.com/getsentry/sentry/blob/master/src/sentry/audit_log/events.py#L93
  15. missing-function-docstring:
    Missing function or method docstring
    https://github.com/getsentry/sentry/blob/master/src/sentry/audit_log/events.py#L108
  16. consider-merging-isinstance:
    Consider merging these isinstance calls to isinstance(filter_name, (bool, set))
    https://github.com/getsentry/sentry/blob/master/src/sentry/audit_log/events.py#L111
  17. use-set-for-membership:
    Consider using set for membership test
    https://github.com/getsentry/sentry/blob/master/src/sentry/audit_log/events.py#L111
  18. consider-using-f-string:
    Formatting a regular string which could be a f-string
    https://github.com/getsentry/sentry/blob/master/src/sentry/audit_log/events.py#L114
  19. missing-class-docstring:
    Missing class docstring
    https://github.com/getsentry/sentry/blob/master/src/sentry/audit_log/events.py#L119
  20. too-few-public-methods:
    Too few public methods (1/2)
    https://github.com/getsentry/sentry/blob/master/src/sentry/audit_log/events.py#L119
  21. missing-class-docstring:
    Missing class docstring
    https://github.com/getsentry/sentry/blob/master/src/sentry/audit_log/events.py#L127
  22. too-few-public-methods:
    Too few public methods (1/2)
    https://github.com/getsentry/sentry/blob/master/src/sentry/audit_log/events.py#L127
  23. missing-class-docstring:
    Missing class docstring
    https://github.com/getsentry/sentry/blob/master/src/sentry/audit_log/events.py#L135
  24. too-few-public-methods:
    Too few public methods (1/2)
    https://github.com/getsentry/sentry/blob/master/src/sentry/audit_log/events.py#L135
  25. missing-class-docstring:
    Missing class docstring
    https://github.com/getsentry/sentry/blob/master/src/sentry/audit_log/events.py#L144
  26. too-few-public-methods:
    Too few public methods (1/2)
    https://github.com/getsentry/sentry/blob/master/src/sentry/audit_log/events.py#L144
  27. missing-class-docstring:
    Missing class docstring
    https://github.com/getsentry/sentry/blob/master/src/sentry/audit_log/events.py#L153
  28. too-few-public-methods:
    Too few public methods (1/2)
    https://github.com/getsentry/sentry/blob/master/src/sentry/audit_log/events.py#L153
  29. missing-class-docstring:
    Missing class docstring
    https://github.com/getsentry/sentry/blob/master/src/sentry/audit_log/events.py#L162
  30. too-few-public-methods:
    Too few public methods (1/2)
    https://github.com/getsentry/sentry/blob/master/src/sentry/audit_log/events.py#L162
  31. missing-class-docstring:
    Missing class docstring
    https://github.com/getsentry/sentry/blob/master/src/sentry/audit_log/events.py#L171
  32. consider-using-f-string:
    Formatting a regular string which could be a f-string
    https://github.com/getsentry/sentry/blob/master/src/sentry/audit_log/events.py#L177
  33. too-few-public-methods:
    Too few public methods (1/2)
    https://github.com/getsentry/sentry/blob/master/src/sentry/audit_log/events.py#L171
  34. missing-class-docstring:
    Missing class docstring
    https://github.com/getsentry/sentry/blob/master/src/sentry/audit_log/events.py#L181
  35. consider-using-f-string:
    Formatting a regular string which could be a f-string
    https://github.com/getsentry/sentry/blob/master/src/sentry/audit_log/events.py#L187
  36. consider-using-f-string:
    Formatting a regular string which could be a f-string
    https://github.com/getsentry/sentry/blob/master/src/sentry/audit_log/events.py#L188
  37. too-few-public-methods:
    Too few public methods (1/2)
    https://github.com/getsentry/sentry/blob/master/src/sentry/audit_log/events.py#L181
  38. missing-class-docstring:
    Missing class docstring
    https://github.com/getsentry/sentry/blob/master/src/sentry/audit_log/events.py#L193
  39. consider-using-f-string:
    Formatting a regular string which could be a f-string
    https://github.com/getsentry/sentry/blob/master/src/sentry/audit_log/events.py#L199
  40. consider-using-f-string:
    Formatting a regular string which could be a f-string
    https://github.com/getsentry/sentry/blob/master/src/sentry/audit_log/events.py#L200
  41. too-few-public-methods:
    Too few public methods (1/2)
    https://github.com/getsentry/sentry/blob/master/src/sentry/audit_log/events.py#L193
  42. missing-class-docstring:
    Missing class docstring
    https://github.com/getsentry/sentry/blob/master/src/sentry/audit_log/events.py#L205
  43. consider-using-f-string:
    Formatting a regular string which could be a f-string
    https://github.com/getsentry/sentry/blob/master/src/sentry/audit_log/events.py#L211
  44. consider-using-f-string:
    Formatting a regular string which could be a f-string
    https://github.com/getsentry/sentry/blob/master/src/sentry/audit_log/events.py#L214
  45. too-few-public-methods:
    Too few public methods (1/2)
    https://github.com/getsentry/sentry/blob/master/src/sentry/audit_log/events.py#L205
  46. missing-class-docstring:
    Missing class docstring
    https://github.com/getsentry/sentry/blob/master/src/sentry/audit_log/events.py#L219
  47. too-few-public-methods:
    Too few public methods (1/2)
    https://github.com/getsentry/sentry/blob/master/src/sentry/audit_log/events.py#L219

The following messages are no longer emitted:

  1. astroid-error:
    *tests/.pylint_primer_tests/getsentry/sentry/src/sentry/audit_log/events.py: Fatal error while checking 'tests/.pylint_primer_tests/getsentry/sentry/src/sentry/audit_log/events.py'. Please open an issue in our bug tracker so we address this. *
    https://github.com/getsentry/sentry/blob/master/src/sentry/audit_log/events.py#L1
  2. wrong-import-position:
    Import "from dataclasses import dataclass" should be placed at the top of the module
    https://github.com/getsentry/sentry/blob/master/src/sentry/audit_log/manager.py#L1
  3. wrong-import-position:
    Import "from typing import List, Optional" should be placed at the top of the module
    https://github.com/getsentry/sentry/blob/master/src/sentry/audit_log/manager.py#L2
  4. wrong-import-position:
    Import "from sentry.models.auditlogentry import AuditLogEntry" should be placed at the top of the module
    https://github.com/getsentry/sentry/blob/master/src/sentry/audit_log/manager.py#L4
  5. wrong-import-order:
    standard import "from dataclasses import dataclass" should be placed before "from sentry.audit_log.manager import AuditLogEvent"
    https://github.com/getsentry/sentry/blob/master/src/sentry/audit_log/manager.py#L1
  6. wrong-import-order:
    standard import "from typing import List, Optional" should be placed before "from sentry.audit_log.manager import AuditLogEvent"
    https://github.com/getsentry/sentry/blob/master/src/sentry/audit_log/manager.py#L2

This comment was generated for commit 7272b43

@jacobtylerwalls jacobtylerwalls merged commit 959a977 into pylint-dev:main Jun 11, 2022
@jacobtylerwalls jacobtylerwalls deleted the constant-gen branch June 11, 2022 13:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement ✨ Improvement to a component
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Raise a warning using-constant-test when casting a generator to a boolean as they are always truthey
4 participants