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

[contextmanager-generator-missing-cleanup][new feature] Warn about @contextlib.contextmanager without try/finally in generator functions #9133

Open
wants to merge 29 commits into
base: main
Choose a base branch
from

Conversation

rhyn0
Copy link
Contributor

@rhyn0 rhyn0 commented Oct 8, 2023

  • add: initial layout for new error
  • add: test cases for new checker
  • add: first pass at new checker

Type of Changes

Type
✨ New feature

Description

Add a checker for contextlib.contextmanager decorated generator functions that don't have cleanup handling for GeneratorExit.

Closes #2832

created new _BasicChecker inheriting class
registered this new linter like the rest in __init__.py
original example case included
a slightly modified positive case
2 negative cases where exception is handled properly
Checks that contextmanager decorated functions that are generators
handle GeneratorExit cleanly
@Pierre-Sassoulas Pierre-Sassoulas added the Enhancement ✨ Improvement to a component label Oct 8, 2023
@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.

Thank you for your contribution, a lot of work went into this clearly. Would you mind adding a good/bad example in https://github.com/pylint-dev/pylint/tree/main/doc/data/messages too ? It's not enforced yet but we're close to being fully documented :)

pylint/checkers/base/function_checker.py Outdated Show resolved Hide resolved
pylint/checkers/base/function_checker.py Outdated Show resolved Hide resolved
pylint/checkers/base/function_checker.py Outdated Show resolved Hide resolved
pylint/checkers/base/function_checker.py Outdated Show resolved Hide resolved
pylint/checkers/base/function_checker.py Outdated Show resolved Hide resolved
pylint/checkers/base/function_checker.py Outdated Show resolved Hide resolved
Changed the detection logic of a bad generator function to test whether
there was attempt at cleanup code
removed extra pylint disables from heading of test cases
output files got updated due to newlines above
@rhyn0 rhyn0 marked this pull request as ready for review October 14, 2023 02:29
@github-actions

This comment has been minimized.

@jacobtylerwalls jacobtylerwalls added the Needs decision 🔒 Needs a decision before implemention or rejection label Nov 5, 2023
@jacobtylerwalls jacobtylerwalls added Needs PR This issue is accepted, sufficiently specified and now needs an implementation Work in progress and removed Needs decision 🔒 Needs a decision before implemention or rejection Needs PR This issue is accepted, sufficiently specified and now needs an implementation labels Feb 19, 2024
@jacobtylerwalls jacobtylerwalls added this to the 3.2.0 milestone Feb 23, 2024
@rhyn0 rhyn0 requested a review from DudeNr33 as a code owner March 3, 2024 21:43
Copy link

codecov bot commented Mar 3, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.83%. Comparing base (e31a155) to head (4d36753).
Report is 175 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #9133      +/-   ##
==========================================
+ Coverage   95.76%   95.83%   +0.07%     
==========================================
  Files         173      174       +1     
  Lines       18665    18885     +220     
==========================================
+ Hits        17874    18098     +224     
+ Misses        791      787       -4     
Files Coverage Δ
pylint/checkers/base/__init__.py 100.00% <100.00%> (ø)
pylint/checkers/base/function_checker.py 100.00% <100.00%> (ø)

... and 39 files with indirect coverage changes

This comment has been minimized.

Copy link
Collaborator

@DanielNoord DanielNoord left a comment

Choose a reason for hiding this comment

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

I have a bit of trouble trying to read the code as there is so much state involved.

It feels like this will only warn whenever the context manager is defined in the same module as the module it is used in, or if the module with the manager is linted before the using module. Shouldn't we be trying to safe_infer the decorator and seeing if it is indeed a "faulty" context manager? That would make it robust against imports as well.
We can still consider caching the result of the check using some state, but since safe_infer should be cached I'm not even sure if that is needed.

@rhyn0
Copy link
Contributor Author

rhyn0 commented Mar 4, 2024

Ahh I didn't know about 'safe_infer'. That would be helpful because I can find the FunctionDef of the used item in the With.

Note for later
'safe_infer(with_node.items[0][0])'

That should allow me to remove the odd state objects in the init.

As for the warnings being on using generator was due to new background from the issue #2832. Using certain context-managers in a generator will cause context leaks which should be warned on the using function rather than the context-manager.

doc/whatsnew/fragments/2832.feature Outdated Show resolved Hide resolved
pylint/checkers/base/function_checker.py Outdated Show resolved Hide resolved
pylint/checkers/base/function_checker.py Show resolved Hide resolved
pylint/checkers/base/function_checker.py Outdated Show resolved Hide resolved
try_with_yield_nodes = [
try_node
for try_node in node.nodes_of_class(nodes.Try)
if list(try_node.nodes_of_class(nodes.Yield))
Copy link
Member

Choose a reason for hiding this comment

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

nit: probably don't need to list-ify this generator

Copy link
Member

Choose a reason for hiding this comment

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

Maybe I'm missing something obvious, but it seemed on a first impression that list is more expensive than any in this instance. Or is that not so?

This comment has been minimized.

This comment has been minimized.

@Pierre-Sassoulas
Copy link
Member

Does this need reviews or do you need to polish some things still @rhyn0 ? I would be glad to have this in 3.2.0 😄

@jacobtylerwalls
Copy link
Member

From what I can tell it's very close:

  • some unresolved documentation comments
  • docs check is failing
  • TODO statements about yield and asyncwith

Happy to give the whole thing a once-over when those are in 👍

This comment has been minimized.

@rhyn0
Copy link
Contributor Author

rhyn0 commented May 5, 2024

Failing ReadTheDocs error seems to be the following

doc/user_guide/messages/warning/implicit-str-concat.rst:55: WARNING: Lexing literal_block '[STRING_CONSTANT]\ncheck-str-concat-over-line-jumps = yes' as "toml" resulted in an error at token: 'y'. Retrying in relaxed mode.

Not sure if I need to change this here

Copy link
Contributor

github-actions bot commented May 5, 2024

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

Effect on astroid:
The following messages are now emitted:

  1. protected-access:
    Access to a protected member _metaclass_lookup_attribute of a client class
    https://github.com/pylint-dev/astroid/blob/2ec0115432af4b4b3757434defc12de6712f7bb9/astroid/manager.py#L462
  2. suppressed-message:
    Suppressed 'import-outside-toplevel' (from line 442)
    https://github.com/pylint-dev/astroid/blob/2ec0115432af4b4b3757434defc12de6712f7bb9/astroid/manager.py#L448
  3. line-too-long:
    Line too long (108/100)
    https://github.com/pylint-dev/astroid/blob/2ec0115432af4b4b3757434defc12de6712f7bb9/astroid/interpreter/_import/spec.py#L257
  4. too-complex:
    'find_module' is too complex. The McCabe rating is 11
    https://github.com/pylint-dev/astroid/blob/2ec0115432af4b4b3757434defc12de6712f7bb9/astroid/interpreter/_import/spec.py#L129
  5. missing-class-docstring:
    Missing class docstring
    https://github.com/pylint-dev/astroid/blob/2ec0115432af4b4b3757434defc12de6712f7bb9/astroid/interpreter/_import/spec.py#L31
  6. missing-function-docstring:
    Missing function or method docstring
    https://github.com/pylint-dev/astroid/blob/2ec0115432af4b4b3757434defc12de6712f7bb9/astroid/interpreter/_import/spec.py#L32
  7. too-few-public-methods:
    Too few public methods (1/2)
    https://github.com/pylint-dev/astroid/blob/2ec0115432af4b4b3757434defc12de6712f7bb9/astroid/interpreter/_import/spec.py#L31
  8. too-many-try-statements:
    try clause contains 5 statements, expected at most 1
    https://github.com/pylint-dev/astroid/blob/2ec0115432af4b4b3757434defc12de6712f7bb9/astroid/interpreter/_import/spec.py#L145
  9. magic-value-comparison:
    Consider using a named constant or an enum instead of ''distutils''.
    https://github.com/pylint-dev/astroid/blob/2ec0115432af4b4b3757434defc12de6712f7bb9/astroid/interpreter/_import/spec.py#L197
  10. missing-function-docstring:
    Missing function or method docstring
    https://github.com/pylint-dev/astroid/blob/2ec0115432af4b4b3757434defc12de6712f7bb9/astroid/interpreter/_import/spec.py#L324
  11. too-many-try-statements:
    try clause contains 2 statements, expected at most 1
    https://github.com/pylint-dev/astroid/blob/2ec0115432af4b4b3757434defc12de6712f7bb9/astroid/interpreter/_import/spec.py#L325
  12. magic-value-comparison:
    Consider using a named constant or an enum instead of 'b'pkgutil''.
    https://github.com/pylint-dev/astroid/blob/2ec0115432af4b4b3757434defc12de6712f7bb9/astroid/interpreter/_import/spec.py#L330
  13. magic-value-comparison:
    Consider using a named constant or an enum instead of 'b'extend_path''.
    https://github.com/pylint-dev/astroid/blob/2ec0115432af4b4b3757434defc12de6712f7bb9/astroid/interpreter/_import/spec.py#L330
  14. magic-value-comparison:
    Consider using a named constant or an enum instead of 'b'pkg_resources''.
    https://github.com/pylint-dev/astroid/blob/2ec0115432af4b4b3757434defc12de6712f7bb9/astroid/interpreter/_import/spec.py#L332
  15. magic-value-comparison:
    Consider using a named constant or an enum instead of 'b'declare_namespace(name)''.
    https://github.com/pylint-dev/astroid/blob/2ec0115432af4b4b3757434defc12de6712f7bb9/astroid/interpreter/_import/spec.py#L332
  16. missing-function-docstring:
    Missing function or method docstring
    https://github.com/pylint-dev/astroid/blob/2ec0115432af4b4b3757434defc12de6712f7bb9/astroid/interpreter/_import/spec.py#L337
  17. missing-function-docstring:
    Missing function or method docstring
    https://github.com/pylint-dev/astroid/blob/2ec0115432af4b4b3757434defc12de6712f7bb9/astroid/interpreter/_import/spec.py#L343
  18. confusing-consecutive-elif:
    Consecutive elif with differing indentation level, consider creating a function to separate the inner elif
    https://github.com/pylint-dev/astroid/blob/2ec0115432af4b4b3757434defc12de6712f7bb9/astroid/interpreter/_import/spec.py#L358
  19. consider-using-f-string:
    Formatting a regular string which could be an f-string
    https://github.com/pylint-dev/astroid/blob/2ec0115432af4b4b3757434defc12de6712f7bb9/astroid/interpreter/_import/spec.py#L355
  20. consider-using-f-string:
    Formatting a regular string which could be an f-string
    https://github.com/pylint-dev/astroid/blob/2ec0115432af4b4b3757434defc12de6712f7bb9/astroid/interpreter/_import/spec.py#L360
  21. missing-function-docstring:
    Missing function or method docstring
    https://github.com/pylint-dev/astroid/blob/2ec0115432af4b4b3757434defc12de6712f7bb9/astroid/interpreter/_import/spec.py#L371
  22. consider-using-assignment-expr:
    Use 'if (meta_finder_name := meta_finder.class.name) not in _MetaPathFinderModuleTypes:' instead
    https://github.com/pylint-dev/astroid/blob/2ec0115432af4b4b3757434defc12de6712f7bb9/astroid/interpreter/_import/spec.py#L391
  23. consider-using-assignment-expr:
    Use 'if (spec := meta_finder.find_spec(modname, submodule_path)):' instead
    https://github.com/pylint-dev/astroid/blob/2ec0115432af4b4b3757434defc12de6712f7bb9/astroid/interpreter/_import/spec.py#L412
  24. missing-function-docstring:
    Missing function or method docstring
    https://github.com/pylint-dev/astroid/blob/2ec0115432af4b4b3757434defc12de6712f7bb9/astroid/interpreter/_import/spec.py#L448
  25. while-used:
    Used while loop
    https://github.com/pylint-dev/astroid/blob/2ec0115432af4b4b3757434defc12de6712f7bb9/astroid/interpreter/_import/spec.py#L458

The following messages are no longer emitted:

  1. protected-access:
    Access to a protected member _metaclass_lookup_attribute of a client class
    https://github.com/pylint-dev/astroid/blob/2ec0115432af4b4b3757434defc12de6712f7bb9/astroid/manager.py#L461
  2. line-too-long:
    Line too long (108/100)
    https://github.com/pylint-dev/astroid/blob/2ec0115432af4b4b3757434defc12de6712f7bb9/astroid/interpreter/_import/spec.py#L256
  3. too-complex:
    'find_module' is too complex. The McCabe rating is 11
    https://github.com/pylint-dev/astroid/blob/2ec0115432af4b4b3757434defc12de6712f7bb9/astroid/interpreter/_import/spec.py#L128
  4. missing-class-docstring:
    Missing class docstring
    https://github.com/pylint-dev/astroid/blob/2ec0115432af4b4b3757434defc12de6712f7bb9/astroid/interpreter/_import/spec.py#L30
  5. missing-function-docstring:
    Missing function or method docstring
    https://github.com/pylint-dev/astroid/blob/2ec0115432af4b4b3757434defc12de6712f7bb9/astroid/interpreter/_import/spec.py#L31
  6. too-few-public-methods:
    Too few public methods (1/2)
    https://github.com/pylint-dev/astroid/blob/2ec0115432af4b4b3757434defc12de6712f7bb9/astroid/interpreter/_import/spec.py#L30
  7. too-many-try-statements:
    try clause contains 5 statements, expected at most 1
    https://github.com/pylint-dev/astroid/blob/2ec0115432af4b4b3757434defc12de6712f7bb9/astroid/interpreter/_import/spec.py#L144
  8. magic-value-comparison:
    Consider using a named constant or an enum instead of ''distutils''.
    https://github.com/pylint-dev/astroid/blob/2ec0115432af4b4b3757434defc12de6712f7bb9/astroid/interpreter/_import/spec.py#L196
  9. missing-function-docstring:
    Missing function or method docstring
    https://github.com/pylint-dev/astroid/blob/2ec0115432af4b4b3757434defc12de6712f7bb9/astroid/interpreter/_import/spec.py#L323
  10. too-many-try-statements:
    try clause contains 2 statements, expected at most 1
    https://github.com/pylint-dev/astroid/blob/2ec0115432af4b4b3757434defc12de6712f7bb9/astroid/interpreter/_import/spec.py#L324
  11. magic-value-comparison:
    Consider using a named constant or an enum instead of 'b'pkgutil''.
    https://github.com/pylint-dev/astroid/blob/2ec0115432af4b4b3757434defc12de6712f7bb9/astroid/interpreter/_import/spec.py#L329
  12. magic-value-comparison:
    Consider using a named constant or an enum instead of 'b'extend_path''.
    https://github.com/pylint-dev/astroid/blob/2ec0115432af4b4b3757434defc12de6712f7bb9/astroid/interpreter/_import/spec.py#L329
  13. magic-value-comparison:
    Consider using a named constant or an enum instead of 'b'pkg_resources''.
    https://github.com/pylint-dev/astroid/blob/2ec0115432af4b4b3757434defc12de6712f7bb9/astroid/interpreter/_import/spec.py#L331
  14. magic-value-comparison:
    Consider using a named constant or an enum instead of 'b'declare_namespace(name)''.
    https://github.com/pylint-dev/astroid/blob/2ec0115432af4b4b3757434defc12de6712f7bb9/astroid/interpreter/_import/spec.py#L331
  15. missing-function-docstring:
    Missing function or method docstring
    https://github.com/pylint-dev/astroid/blob/2ec0115432af4b4b3757434defc12de6712f7bb9/astroid/interpreter/_import/spec.py#L336
  16. missing-function-docstring:
    Missing function or method docstring
    https://github.com/pylint-dev/astroid/blob/2ec0115432af4b4b3757434defc12de6712f7bb9/astroid/interpreter/_import/spec.py#L342
  17. confusing-consecutive-elif:
    Consecutive elif with differing indentation level, consider creating a function to separate the inner elif
    https://github.com/pylint-dev/astroid/blob/2ec0115432af4b4b3757434defc12de6712f7bb9/astroid/interpreter/_import/spec.py#L357
  18. consider-using-f-string:
    Formatting a regular string which could be an f-string
    https://github.com/pylint-dev/astroid/blob/2ec0115432af4b4b3757434defc12de6712f7bb9/astroid/interpreter/_import/spec.py#L354
  19. consider-using-f-string:
    Formatting a regular string which could be an f-string
    https://github.com/pylint-dev/astroid/blob/2ec0115432af4b4b3757434defc12de6712f7bb9/astroid/interpreter/_import/spec.py#L359
  20. missing-function-docstring:
    Missing function or method docstring
    https://github.com/pylint-dev/astroid/blob/2ec0115432af4b4b3757434defc12de6712f7bb9/astroid/interpreter/_import/spec.py#L370
  21. consider-using-assignment-expr:
    Use 'if (meta_finder_name := meta_finder.class.name) not in _MetaPathFinderModuleTypes:' instead
    https://github.com/pylint-dev/astroid/blob/2ec0115432af4b4b3757434defc12de6712f7bb9/astroid/interpreter/_import/spec.py#L390
  22. consider-using-assignment-expr:
    Use 'if (spec := meta_finder.find_spec(modname, submodule_path)):' instead
    https://github.com/pylint-dev/astroid/blob/2ec0115432af4b4b3757434defc12de6712f7bb9/astroid/interpreter/_import/spec.py#L411
  23. while-used:
    Used while loop
    https://github.com/pylint-dev/astroid/blob/2ec0115432af4b4b3757434defc12de6712f7bb9/astroid/interpreter/_import/spec.py#L452

Effect on home-assistant:
The following messages are now emitted:

  1. unused-argument:
    Unused argument 'hass'
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/androidtv_remote/diagnostics.py#L17
  2. unused-argument:
    Unused argument 'hass'
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/androidtv_remote/media_player.py#L28
  3. abstract-method:
    Method 'async_browse_media' is abstract in class 'MediaPlayerEntity' but is not overridden in child class 'AndroidTVRemoteMediaPlayerEntity'
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/androidtv_remote/media_player.py#L37
  4. abstract-method:
    Method 'clear_playlist' is abstract in class 'MediaPlayerEntity' but is not overridden in child class 'AndroidTVRemoteMediaPlayerEntity'
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/androidtv_remote/media_player.py#L37
  5. abstract-method:
    Method 'join_players' is abstract in class 'MediaPlayerEntity' but is not overridden in child class 'AndroidTVRemoteMediaPlayerEntity'
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/androidtv_remote/media_player.py#L37
  6. abstract-method:
    Method 'media_next_track' is abstract in class 'MediaPlayerEntity' but is not overridden in child class 'AndroidTVRemoteMediaPlayerEntity'
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/androidtv_remote/media_player.py#L37
  7. abstract-method:
    Method 'media_pause' is abstract in class 'MediaPlayerEntity' but is not overridden in child class 'AndroidTVRemoteMediaPlayerEntity'
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/androidtv_remote/media_player.py#L37
  8. abstract-method:
    Method 'media_play' is abstract in class 'MediaPlayerEntity' but is not overridden in child class 'AndroidTVRemoteMediaPlayerEntity'
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/androidtv_remote/media_player.py#L37
  9. abstract-method:
    Method 'media_previous_track' is abstract in class 'MediaPlayerEntity' but is not overridden in child class 'AndroidTVRemoteMediaPlayerEntity'
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/androidtv_remote/media_player.py#L37
  10. abstract-method:
    Method 'media_seek' is abstract in class 'MediaPlayerEntity' but is not overridden in child class 'AndroidTVRemoteMediaPlayerEntity'
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/androidtv_remote/media_player.py#L37
  11. abstract-method:
    Method 'media_stop' is abstract in class 'MediaPlayerEntity' but is not overridden in child class 'AndroidTVRemoteMediaPlayerEntity'
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/androidtv_remote/media_player.py#L37
  12. abstract-method:
    Method 'mute_volume' is abstract in class 'MediaPlayerEntity' but is not overridden in child class 'AndroidTVRemoteMediaPlayerEntity'
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/androidtv_remote/media_player.py#L37
  13. abstract-method:
    Method 'play_media' is abstract in class 'MediaPlayerEntity' but is not overridden in child class 'AndroidTVRemoteMediaPlayerEntity'
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/androidtv_remote/media_player.py#L37
  14. abstract-method:
    Method 'select_sound_mode' is abstract in class 'MediaPlayerEntity' but is not overridden in child class 'AndroidTVRemoteMediaPlayerEntity'
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/androidtv_remote/media_player.py#L37
  15. abstract-method:
    Method 'select_source' is abstract in class 'MediaPlayerEntity' but is not overridden in child class 'AndroidTVRemoteMediaPlayerEntity'
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/androidtv_remote/media_player.py#L37
  16. abstract-method:
    Method 'set_repeat' is abstract in class 'MediaPlayerEntity' but is not overridden in child class 'AndroidTVRemoteMediaPlayerEntity'
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/androidtv_remote/media_player.py#L37
  17. abstract-method:
    Method 'set_shuffle' is abstract in class 'MediaPlayerEntity' but is not overridden in child class 'AndroidTVRemoteMediaPlayerEntity'
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/androidtv_remote/media_player.py#L37
  18. abstract-method:
    Method 'set_volume_level' is abstract in class 'MediaPlayerEntity' but is not overridden in child class 'AndroidTVRemoteMediaPlayerEntity'
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/androidtv_remote/media_player.py#L37
  19. abstract-method:
    Method 'turn_off' is abstract in class 'MediaPlayerEntity' but is not overridden in child class 'AndroidTVRemoteMediaPlayerEntity'
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/androidtv_remote/media_player.py#L37
  20. abstract-method:
    Method 'turn_on' is abstract in class 'MediaPlayerEntity' but is not overridden in child class 'AndroidTVRemoteMediaPlayerEntity'
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/androidtv_remote/media_player.py#L37
  21. abstract-method:
    Method 'unjoin_player' is abstract in class 'MediaPlayerEntity' but is not overridden in child class 'AndroidTVRemoteMediaPlayerEntity'
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/androidtv_remote/media_player.py#L37
  22. too-many-try-statements:
    try clause contains 3 statements, expected at most 1
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/androidtv_remote/media_player.py#L193
  23. too-many-try-statements:
    try clause contains 2 statements, expected at most 1
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/androidtv_remote/__init__.py#L50
  24. unused-argument:
    Unused argument 'event'
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/androidtv_remote/__init__.py#L75
  25. unused-argument:
    Unused argument 'hass'
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/androidtv_remote/remote.py#L30
  26. abstract-method:
    Method 'delete_command' is abstract in class 'RemoteEntity' but is not overridden in child class 'AndroidTVRemoteEntity'
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/androidtv_remote/remote.py#L39
  27. abstract-method:
    Method 'learn_command' is abstract in class 'RemoteEntity' but is not overridden in child class 'AndroidTVRemoteEntity'
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/androidtv_remote/remote.py#L39
  28. abstract-method:
    Method 'send_command' is abstract in class 'RemoteEntity' but is not overridden in child class 'AndroidTVRemoteEntity'
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/androidtv_remote/remote.py#L39
  29. abstract-method:
    Method 'turn_off' is abstract in class 'ToggleEntity' but is not overridden in child class 'AndroidTVRemoteEntity'
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/androidtv_remote/remote.py#L39
  30. abstract-method:
    Method 'turn_on' is abstract in class 'ToggleEntity' but is not overridden in child class 'AndroidTVRemoteEntity'
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/androidtv_remote/remote.py#L39
  31. consider-using-assignment-expr:
    Use 'if (activity := kwargs.get(ATTR_ACTIVITY, '')):' instead
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/androidtv_remote/remote.py#L68
  32. unexpected-keyword-arg:
    Unexpected keyword argument 'key' in constructor call
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/habitica/sensor.py#L54
  33. unexpected-keyword-arg:
    Unexpected keyword argument 'translation_key' in constructor call
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/habitica/sensor.py#L54
  34. unexpected-keyword-arg:
    Unexpected keyword argument 'key' in constructor call
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/habitica/sensor.py#L59
  35. unexpected-keyword-arg:
    Unexpected keyword argument 'translation_key' in constructor call
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/habitica/sensor.py#L59
  36. unexpected-keyword-arg:
    Unexpected keyword argument 'native_unit_of_measurement' in constructor call
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/habitica/sensor.py#L59
  37. unexpected-keyword-arg:
    Unexpected keyword argument 'suggested_display_precision' in constructor call
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/habitica/sensor.py#L59
  38. unexpected-keyword-arg:
    Unexpected keyword argument 'key' in constructor call
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/habitica/sensor.py#L66
  39. unexpected-keyword-arg:
    Unexpected keyword argument 'translation_key' in constructor call
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/habitica/sensor.py#L66
  40. unexpected-keyword-arg:
    Unexpected keyword argument 'native_unit_of_measurement' in constructor call
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/habitica/sensor.py#L66
  41. unexpected-keyword-arg:
    Unexpected keyword argument 'entity_registry_enabled_default' in constructor call
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/habitica/sensor.py#L66
  42. unexpected-keyword-arg:
    Unexpected keyword argument 'key' in constructor call
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/habitica/sensor.py#L73
  43. unexpected-keyword-arg:
    Unexpected keyword argument 'translation_key' in constructor call
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/habitica/sensor.py#L73
  44. unexpected-keyword-arg:
    Unexpected keyword argument 'native_unit_of_measurement' in constructor call
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/habitica/sensor.py#L73
  45. unexpected-keyword-arg:
    Unexpected keyword argument 'suggested_display_precision' in constructor call
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/habitica/sensor.py#L73
  46. unexpected-keyword-arg:
    Unexpected keyword argument 'key' in constructor call
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/habitica/sensor.py#L80
  47. unexpected-keyword-arg:
    Unexpected keyword argument 'translation_key' in constructor call
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/habitica/sensor.py#L80
  48. unexpected-keyword-arg:
    Unexpected keyword argument 'native_unit_of_measurement' in constructor call
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/habitica/sensor.py#L80
  49. unexpected-keyword-arg:
    Unexpected keyword argument 'key' in constructor call
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/habitica/sensor.py#L86
  50. unexpected-keyword-arg:
    Unexpected keyword argument 'translation_key' in constructor call
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/habitica/sensor.py#L86
  51. unexpected-keyword-arg:
    Unexpected keyword argument 'native_unit_of_measurement' in constructor call
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/habitica/sensor.py#L86
  52. unexpected-keyword-arg:
    Unexpected keyword argument 'key' in constructor call
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/habitica/sensor.py#L92
  53. unexpected-keyword-arg:
    Unexpected keyword argument 'translation_key' in constructor call
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/habitica/sensor.py#L92
  54. unexpected-keyword-arg:
    Unexpected keyword argument 'native_unit_of_measurement' in constructor call
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/habitica/sensor.py#L92
  55. unexpected-keyword-arg:
    Unexpected keyword argument 'key' in constructor call
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/habitica/sensor.py#L98
  56. unexpected-keyword-arg:
    Unexpected keyword argument 'translation_key' in constructor call
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/habitica/sensor.py#L98
  57. unexpected-keyword-arg:
    Unexpected keyword argument 'key' in constructor call
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/habitica/sensor.py#L103
  58. unexpected-keyword-arg:
    Unexpected keyword argument 'translation_key' in constructor call
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/habitica/sensor.py#L103
  59. unexpected-keyword-arg:
    Unexpected keyword argument 'native_unit_of_measurement' in constructor call
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/habitica/sensor.py#L103
  60. unexpected-keyword-arg:
    Unexpected keyword argument 'suggested_display_precision' in constructor call
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/habitica/sensor.py#L103
  61. unexpected-keyword-arg:
    Unexpected keyword argument 'key' in constructor call
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/habitica/sensor.py#L110
  62. unexpected-keyword-arg:
    Unexpected keyword argument 'translation_key' in constructor call
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/habitica/sensor.py#L110
  63. unexpected-keyword-arg:
    Unexpected keyword argument 'device_class' in constructor call
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/habitica/sensor.py#L110
  64. unexpected-keyword-arg:
    Unexpected keyword argument 'options' in constructor call
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/habitica/sensor.py#L110
  65. prefer-typing-namedtuple:
    Prefer 'typing.NamedTuple' over 'collections.namedtuple'
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/habitica/sensor.py#L119
  66. unused-argument:
    Unused argument 'hass'
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/habitica/sensor.py#L162
  67. too-complex:
    'async_setup_entry' is too complex. The McCabe rating is 14
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/habitica/__init__.py#L113
  68. import-error:
    Unable to import 'aiohttp'
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/habitica/__init__.py#L6
  69. import-error:
    Unable to import 'habitipy.aio'
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/habitica/__init__.py#L7
  70. import-error:
    Unable to import 'voluptuous'
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/habitica/__init__.py#L8
  71. too-few-public-methods:
    Too few public methods (1/2)
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/habitica/__init__.py#L116
  72. too-many-try-statements:
    try clause contains 2 statements, expected at most 1
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/habitica/__init__.py#L134
  73. import-error:
    Unable to import 'aiohttp'
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/habitica/coordinator.py#L10
  74. import-error:
    Unable to import 'habitipy.aio'
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/habitica/coordinator.py#L11
  75. too-many-try-statements:
    try clause contains 4 statements, expected at most 1
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/habitica/coordinator.py#L48
  76. too-many-try-statements:
    try clause contains 2 statements, expected at most 1
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/bring/__init__.py#L39
  77. unused-argument:
    Unused argument 'hass'
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/bring/todo.py#L36
  78. too-many-lines:
    Too many lines in module (1028/1000)
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/nut/sensor.py#L1
  79. unused-argument:
    Unused argument 'hass'
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/nut/sensor.py#L961
  80. consider-using-assignment-expr:
    Use 'if not (runtime_data := _get_runtime_data_from_device_id(hass, device_id)):' instead
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/nut/device_action.py#L53
  81. unused-argument:
    Unused argument 'variables'
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/nut/device_action.py#L45
  82. unused-argument:
    Unused argument 'context'
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/nut/device_action.py#L46
  83. magic-value-comparison:
    Consider using a named constant or an enum instead of ''entity_id''.
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/nut/diagnostics.py#L68
  84. too-many-locals:
    Too many local variables (18/15)
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/nut/__init__.py#L52
  85. consider-using-assignment-expr:
    Use 'if (unique_id := _unique_id_from_status(status)) is None:' instead
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/nut/__init__.py#L109
  86. consider-ternary-expression:
    Consider rewriting as a ternary expression
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/nut/__init__.py#L112
  87. consider-using-assignment-expr:
    Use 'if not (serial := _serial_from_status(status)):' instead
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/nut/__init__.py#L188
  88. too-many-arguments:
    Too many arguments (7/5)
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/nut/__init__.py#L220
  89. magic-value-comparison:
    Consider using a named constant or an enum instead of ''name''.
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/conversation/http.py#L272
  90. magic-value-comparison:
    Consider using a named constant or an enum instead of ''area''.
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/conversation/http.py#L275
  91. magic-value-comparison:
    Consider using a named constant or an enum instead of ''domain''.
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/conversation/http.py#L278
  92. magic-value-comparison:
    Consider using a named constant or an enum instead of ''device_class''.
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/conversation/http.py#L281
  93. magic-value-comparison:
    Consider using a named constant or an enum instead of ''state''.
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/conversation/http.py#L284
  94. locally-disabled:
    Locally disabling import-outside-toplevel (C0415)
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/mqtt/config_flow.py#L835
  95. too-complex:
    'async_step_options' is too complex. The McCabe rating is 12
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/mqtt/config_flow.py#L390
  96. too-complex:
    'async_get_broker_settings' is too complex. The McCabe rating is 25
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/mqtt/config_flow.py#L537
  97. too-complex:
    'check_certicate_chain' is too complex. The McCabe rating is 13
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/mqtt/config_flow.py#L865
  98. unused-argument:
    Unused argument 'user_input'
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/mqtt/config_flow.py#L349
  99. too-many-try-statements:
    try clause contains 2 statements, expected at most 1
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/mqtt/config_flow.py#L418
  100. magic-value-comparison:
    Consider using a named constant or an enum instead of ''birth_topic''.
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/mqtt/config_flow.py#L434
  101. magic-value-comparison:
    Consider using a named constant or an enum instead of ''will_topic''.
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/mqtt/config_flow.py#L444
  102. too-many-arguments:
    Too many arguments (6/5)
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/mqtt/config_flow.py#L537
  103. too-many-locals:
    Too many local variables (27/15)
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/mqtt/config_flow.py#L537
  104. too-many-locals:
    Too many local variables (16/15)
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/mqtt/config_flow.py#L558
  105. magic-value-comparison:
    Consider using a named constant or an enum instead of ''auto''.
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/mqtt/config_flow.py#L569
  106. magic-value-comparison:
    Consider using a named constant or an enum instead of ''custom''.
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/mqtt/config_flow.py#L571
  107. consider-using-assignment-expr:
    Use 'if (certificate_id := user_input.get(CONF_CERTIFICATE)):' instead
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/mqtt/config_flow.py#L594
  108. too-many-boolean-expressions:
    Too many boolean expressions in if statement (8/5)
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/mqtt/config_flow.py#L600
  109. magic-value-comparison:
    Consider using a named constant or an enum instead of ''custom''.
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/mqtt/config_flow.py#L604
  110. too-many-try-statements:
    try clause contains 3 statements, expected at most 1
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/mqtt/config_flow.py#L647
  111. too-many-branches:
    Too many branches (14/12)
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/mqtt/config_flow.py#L558
  112. magic-value-comparison:
    Consider using a named constant or an enum instead of ''off''.
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/mqtt/config_flow.py#L710
  113. magic-value-comparison:
    Consider using a named constant or an enum instead of ''auto''.
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/mqtt/config_flow.py#L781
  114. magic-value-comparison:
    Consider using a named constant or an enum instead of ''custom''.
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/mqtt/config_flow.py#L790
  115. too-many-statements:
    Too many statements (99/50)
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/mqtt/config_flow.py#L537
  116. import-error:
    Unable to import 'paho.mqtt.client'
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/mqtt/config_flow.py#L835
  117. unused-argument:
    Unused argument 'client_'
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/mqtt/config_flow.py#L842
  118. unused-argument:
    Unused argument 'userdata'
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/mqtt/config_flow.py#L843
  119. unused-argument:
    Unused argument 'flags'
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/mqtt/config_flow.py#L844
  120. unused-argument:
    Unused argument 'properties'
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/mqtt/config_flow.py#L846
  121. too-many-try-statements:
    try clause contains 2 statements, expected at most 1
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/mqtt/config_flow.py#L868
  122. too-many-try-statements:
    try clause contains 2 statements, expected at most 1
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/mqtt/config_flow.py#L875
  123. suppressed-message:
    Suppressed 'import-outside-toplevel' (from line 835)
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/mqtt/config_flow.py#L835
  124. unused-argument:
    Unused argument 'hass'
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/pi_hole/sensor.py#L66
  125. unexpected-keyword-arg:
    Unexpected keyword argument 'key' in constructor call
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/pi_hole/binary_sensor.py#L32
  126. unexpected-keyword-arg:
    Unexpected keyword argument 'translation_key' in constructor call
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/pi_hole/binary_sensor.py#L32
  127. magic-value-comparison:
    Consider using a named constant or an enum instead of ''enabled''.
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/pi_hole/binary_sensor.py#L35
  128. unused-argument:
    Unused argument 'hass'
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/pi_hole/binary_sensor.py#L41
  129. unused-argument:
    Unused argument 'hass'
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/pi_hole/diagnostics.py#L17
  130. unused-argument:
    Unused argument 'hass'
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/pi_hole/switch.py#L24
  131. abstract-method:
    Method 'turn_off' is abstract in class 'ToggleEntity' but is not overridden in child class 'PiHoleSwitch'
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/pi_hole/switch.py#L54
  132. abstract-method:
    Method 'turn_on' is abstract in class 'ToggleEntity' but is not overridden in child class 'PiHoleSwitch'
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/pi_hole/switch.py#L54
  133. magic-value-comparison:
    Consider using a named constant or an enum instead of ''enabled''.
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/pi_hole/switch.py#L72
  134. too-many-try-statements:
    try clause contains 2 statements, expected at most 1
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/pi_hole/switch.py#L76
  135. too-many-try-statements:
    try clause contains 2 statements, expected at most 1
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/pi_hole/switch.py#L97
  136. import-error:
    Unable to import 'hole'
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/pi_hole/__init__.py#L8
  137. import-error:
    Unable to import 'hole.exceptions'
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/pi_hole/__init__.py#L9
  138. magic-value-comparison:
    Consider using a named constant or an enum instead of '2'.
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/pi_hole/__init__.py#L95
  139. too-many-try-statements:
    try clause contains 2 statements, expected at most 1
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/pi_hole/__init__.py#L116
  140. consider-ternary-expression:
    Consider rewriting as a ternary expression
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/pi_hole/__init__.py#L165
  141. unexpected-keyword-arg:
    Unexpected keyword argument 'key' in constructor call
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/pi_hole/update.py#L30
  142. unexpected-keyword-arg:
    Unexpected keyword argument 'translation_key' in constructor call
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/pi_hole/update.py#L30
  143. unexpected-keyword-arg:
    Unexpected keyword argument 'entity_category' in constructor call
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/pi_hole/update.py#L30
  144. unexpected-keyword-arg:
    Unexpected keyword argument 'key' in constructor call
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/pi_hole/update.py#L39
  145. unexpected-keyword-arg:
    Unexpected keyword argument 'translation_key' in constructor call
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/pi_hole/update.py#L39
  146. unexpected-keyword-arg:
    Unexpected keyword argument 'entity_category' in constructor call
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/pi_hole/update.py#L39
  147. unexpected-keyword-arg:
    Unexpected keyword argument 'key' in constructor call
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/pi_hole/update.py#L48
  148. unexpected-keyword-arg:
    Unexpected keyword argument 'translation_key' in constructor call
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/pi_hole/update.py#L48
  149. unexpected-keyword-arg:
    Unexpected keyword argument 'entity_category' in constructor call
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/pi_hole/update.py#L48
  150. unused-argument:
    Unused argument 'hass'
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/pi_hole/update.py#L61
  151. unused-argument:
    Unused argument 'hass'
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/cert_expiry/sensor.py#L64
  152. import-error:
    Unable to import 'boschshcpy'
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/bosch_shc/sensor.py#L9
  153. import-error:
    Unable to import 'boschshcpy.device'
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/bosch_shc/sensor.py#L10
  154. unexpected-keyword-arg:
    Unexpected keyword argument 'key' in constructor call
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/bosch_shc/sensor.py#L55
  155. unexpected-keyword-arg:
    Unexpected keyword argument 'device_class' in constructor call
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/bosch_shc/sensor.py#L55
  156. unexpected-keyword-arg:
    Unexpected keyword argument 'state_class' in constructor call
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/bosch_shc/sensor.py#L55
  157. unexpected-keyword-arg:
    Unexpected keyword argument 'native_unit_of_measurement' in constructor call
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/bosch_shc/sensor.py#L55
  158. unexpected-keyword-arg:
    Unexpected keyword argument 'key' in constructor call
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/bosch_shc/sensor.py#L62
  159. unexpected-keyword-arg:
    Unexpected keyword argument 'device_class' in constructor call
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/bosch_shc/sensor.py#L62
  160. unexpected-keyword-arg:
    Unexpected keyword argument 'native_unit_of_measurement' in constructor call
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/bosch_shc/sensor.py#L62
  161. unexpected-keyword-arg:
    Unexpected keyword argument 'key' in constructor call
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/bosch_shc/sensor.py#L68
  162. unexpected-keyword-arg:
    Unexpected keyword argument 'translation_key' in constructor call
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/bosch_shc/sensor.py#L68
  163. unexpected-keyword-arg:
    Unexpected keyword argument 'native_unit_of_measurement' in constructor call
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/bosch_shc/sensor.py#L68
  164. unexpected-keyword-arg:
    Unexpected keyword argument 'key' in constructor call
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/bosch_shc/sensor.py#L74
  165. unexpected-keyword-arg:
    Unexpected keyword argument 'translation_key' in constructor call
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/bosch_shc/sensor.py#L74
  166. unexpected-keyword-arg:
    Unexpected keyword argument 'key' in constructor call
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/bosch_shc/sensor.py#L82
  167. unexpected-keyword-arg:
    Unexpected keyword argument 'translation_key' in constructor call
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/bosch_shc/sensor.py#L82
  168. unexpected-keyword-arg:
    Unexpected keyword argument 'key' in constructor call
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/bosch_shc/sensor.py#L87
  169. unexpected-keyword-arg:
    Unexpected keyword argument 'translation_key' in constructor call
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/bosch_shc/sensor.py#L87
  170. unexpected-keyword-arg:
    Unexpected keyword argument 'key' in constructor call
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/bosch_shc/sensor.py#L92
  171. unexpected-keyword-arg:
    Unexpected keyword argument 'translation_key' in constructor call
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/bosch_shc/sensor.py#L92
  172. unexpected-keyword-arg:
    Unexpected keyword argument 'key' in constructor call
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/bosch_shc/sensor.py#L97
  173. unexpected-keyword-arg:
    Unexpected keyword argument 'translation_key' in constructor call
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/bosch_shc/sensor.py#L97
  174. unexpected-keyword-arg:
    Unexpected keyword argument 'key' in constructor call
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/bosch_shc/sensor.py#L102
  175. unexpected-keyword-arg:
    Unexpected keyword argument 'device_class' in constructor call
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/bosch_shc/sensor.py#L102
  176. unexpected-keyword-arg:
    Unexpected keyword argument 'native_unit_of_measurement' in constructor call
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/bosch_shc/sensor.py#L102
  177. unexpected-keyword-arg:
    Unexpected keyword argument 'key' in constructor call
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/bosch_shc/sensor.py#L108
  178. unexpected-keyword-arg:
    Unexpected keyword argument 'device_class' in constructor call
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/bosch_shc/sensor.py#L108
  179. unexpected-keyword-arg:
    Unexpected keyword argument 'state_class' in constructor call
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/bosch_shc/sensor.py#L108
  180. unexpected-keyword-arg:
    Unexpected keyword argument 'native_unit_of_measurement' in constructor call
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/bosch_shc/sensor.py#L108
  181. unexpected-keyword-arg:
    Unexpected keyword argument 'key' in constructor call
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/bosch_shc/sensor.py#L115
  182. unexpected-keyword-arg:
    Unexpected keyword argument 'translation_key' in constructor call
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/bosch_shc/sensor.py#L115
  183. unexpected-keyword-arg:
    Unexpected keyword argument 'state_class' in constructor call
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/bosch_shc/sensor.py#L115
  184. unexpected-keyword-arg:
    Unexpected keyword argument 'native_unit_of_measurement' in constructor call
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/bosch_shc/sensor.py#L115
  185. unexpected-keyword-arg:
    Unexpected keyword argument 'key' in constructor call
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/sun/sensor.py#L38
  186. unexpected-keyword-arg:
    Unexpected keyword argument 'device_class' in constructor call
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/sun/sensor.py#L38
  187. unexpected-keyword-arg:
    Unexpected keyword argument 'translation_key' in constructor call
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/sun/sensor.py#L38
  188. unexpected-keyword-arg:
    Unexpected keyword argument 'key' in constructor call
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/sun/sensor.py#L45
  189. unexpected-keyword-arg:
    Unexpected keyword argument 'device_class' in constructor call
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/sun/sensor.py#L45
  190. unexpected-keyword-arg:
    Unexpected keyword argument 'translation_key' in constructor call
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/sun/sensor.py#L45
  191. unexpected-keyword-arg:
    Unexpected keyword argument 'key' in constructor call
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/sun/sensor.py#L52
  192. unexpected-keyword-arg:
    Unexpected keyword argument 'device_class' in constructor call
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/sun/sensor.py#L52
  193. unexpected-keyword-arg:
    Unexpected keyword argument 'translation_key' in constructor call
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/sun/sensor.py#L52
  194. unexpected-keyword-arg:
    Unexpected keyword argument 'key' in constructor call
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/sun/sensor.py#L59
  195. unexpected-keyword-arg:
    Unexpected keyword argument 'device_class' in constructor call
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/sun/sensor.py#L59
  196. unexpected-keyword-arg:
    Unexpected keyword argument 'translation_key' in constructor call
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/sun/sensor.py#L59
  197. unexpected-keyword-arg:
    Unexpected keyword argument 'key' in constructor call
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/sun/sensor.py#L66
  198. unexpected-keyword-arg:
    Unexpected keyword argument 'device_class' in constructor call
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/sun/sensor.py#L66
  199. unexpected-keyword-arg:
    Unexpected keyword argument 'translation_key' in constructor call
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/sun/sensor.py#L66
  200. unexpected-keyword-arg:
    Unexpected keyword argument 'key' in constructor call
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/sun/sensor.py#L73
  201. unexpected-keyword-arg:
    Unexpected keyword argument 'device_class' in constructor call
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/sun/sensor.py#L73
  202. unexpected-keyword-arg:
    Unexpected keyword argument 'translation_key' in constructor call
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/sun/sensor.py#L73
  203. unexpected-keyword-arg:
    Unexpected keyword argument 'key' in constructor call
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/sun/sensor.py#L80
  204. unexpected-keyword-arg:
    Unexpected keyword argument 'translation_key' in constructor call
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/sun/sensor.py#L80
  205. unexpected-keyword-arg:
    Unexpected keyword argument 'state_class' in constructor call
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/sun/sensor.py#L80
  206. unexpected-keyword-arg:
    Unexpected keyword argument 'entity_registry_enabled_default' in constructor call
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/sun/sensor.py#L80
  207. unexpected-keyword-arg:
    Unexpected keyword argument 'native_unit_of_measurement' in constructor call
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/sun/sensor.py#L80
  208. unexpected-keyword-arg:
    Unexpected keyword argument 'key' in constructor call
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/sun/sensor.py#L89
  209. unexpected-keyword-arg:
    Unexpected keyword argument 'translation_key' in constructor call
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/sun/sensor.py#L89
  210. unexpected-keyword-arg:
    Unexpected keyword argument 'state_class' in constructor call
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/sun/sensor.py#L89
  211. unexpected-keyword-arg:
    Unexpected keyword argument 'entity_registry_enabled_default' in constructor call
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/sun/sensor.py#L89
  212. unexpected-keyword-arg:
    Unexpected keyword argument 'native_unit_of_measurement' in constructor call
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/sun/sensor.py#L89
  213. unexpected-keyword-arg:
    Unexpected keyword argument 'key' in constructor call
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/sun/sensor.py#L98
  214. unexpected-keyword-arg:
    Unexpected keyword argument 'translation_key' in constructor call
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/sun/sensor.py#L98
  215. unexpected-keyword-arg:
    Unexpected keyword argument 'entity_registry_enabled_default' in constructor call
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/sun/sensor.py#L98
  216. unused-argument:
    Unused argument 'hass'
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/sun/sensor.py#L109
  217. line-too-long:
    Line too long (111/100)
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/sun/entity.py#L128
  218. too-many-instance-attributes:
    Too many instance attributes (18/7)
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/sun/entity.py#L84
  219. no-member:
    Instance of 'Sun' has no '_Entity__combined_unrecorded_attributes' member
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/sun/entity.py#L128
  220. magic-value-comparison:
    Consider using a named constant or an enum instead of '10'.
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/sun/entity.py#L238
  221. unused-argument:
    Unused argument 'now'
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/sun/entity.py#L197
  222. redefined-variable-type:
    Redefinition of self.location.solar_depression type from str to int
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/sun/entity.py#L216
  223. unused-argument:
    Unused argument 'now'
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/sun/entity.py#L268
  224. unused-argument:
    Unused argument 'hass'
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/speedtestdotnet/sensor.py#L71
  225. consider-using-assignment-expr:
    *Use 'if (server_name := user_input[CONF_SERVER_NAME]) != 'Auto Detect':' instead
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/speedtestdotnet/config_flow.py#L64
  226. magic-value-comparison:
    *Consider using a named constant or an enum instead of ''Auto Detect''.
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/speedtestdotnet/config_flow.py#L64
  227. too-many-try-statements:
    try clause contains 2 statements, expected at most 1
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/speedtestdotnet/__init__.py#L26
  228. unused-argument:
    Unused argument 'hass'
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/speedtestdotnet/__init__.py#L36
  229. import-error:
    Unable to import 'aiohttp.client_exceptions'
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/nam/__init__.py#L8
  230. import-error:
    Unable to import 'nettigo_air_monitor'
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/nam/__init__.py#L9
  231. import-error:
    Unable to import 'aiohttp.client_exceptions'
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/nam/coordinator.py#L6
  232. import-error:
    Unable to import 'nettigo_air_monitor'
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/nam/coordinator.py#L7
  233. too-many-try-statements:
    try clause contains 2 statements, expected at most 1
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/nam/coordinator.py#L49
  234. too-few-public-methods:
    Too few public methods (0/2)
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/nam/coordinator.py#L23
  235. line-too-long:
    Line too long (113/100)
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/synology_dsm/config_flow.py#L271
  236. too-complex:
    'async_validate_input_create_entry' is too complex. The McCabe rating is 15
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/synology_dsm/config_flow.py#L161
  237. magic-value-comparison:
    Consider using a named constant or an enum instead of ''link''.
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/synology_dsm/config_flow.py#L145
  238. magic-value-comparison:
    Consider using a named constant or an enum instead of ''reauth_confirm''.
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/synology_dsm/config_flow.py#L149
  239. magic-value-comparison:
    Consider using a named constant or an enum instead of ''user''.
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/synology_dsm/config_flow.py#L151
  240. too-many-locals:
    Too many local variables (19/15)
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/synology_dsm/config_flow.py#L161
  241. too-many-branches:
    Too many branches (14/12)
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/synology_dsm/config_flow.py#L161
  242. too-complex:
    '_setup_api_requests' is too complex. The McCabe rating is 15
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/synology_dsm/common.py#L185
  243. import-error:
    Unable to import 'synology_dsm'
    https://github.com/home-assistant/core/blob/ee031f485028ef5871d0fce3644d0b6f88351535/homeassistant/components/synology_dsm/common.py#L10
  244. import-error:
    Unable to import 'synology_dsm.api.core.security'
    https://github.com/home-assistant/core/blob/ee031f485028...

This comment was truncated because GitHub allows only 65536 characters in a comment.

This comment was generated for commit 4d36753

Copy link
Member

@jacobtylerwalls jacobtylerwalls left a comment

Choose a reason for hiding this comment

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

Looking forward to merging this shortly. Just some minor feedback.

because the ways to use a contextmanager are many.
A contextmanager can be used as a decorator (which immediately has ``__enter__``/``__exit__`` applied)
and the use ``as ...`` or discard of the return value also implies whether the context needs cleanup or not.
So for this message, warning the invoker of the contextmanager is important.
Copy link
Member

Choose a reason for hiding this comment

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

Thanks, this is really great. A really subtle set of circumstances explained very clearly.

This message warns on the generator function instead of the contextmanager function
because the ways to use a contextmanager are many.
A contextmanager can be used as a decorator (which immediately has ``__enter__``/``__exit__`` applied)
and the use ``as ...`` or discard of the return value also implies whether the context needs cleanup or not.
Copy link
Member

Choose a reason for hiding this comment

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

use -> use of

@@ -0,0 +1,6 @@
Checks for generators that use contextmanagers that don't handle cleanup properly.
Is meant to raise visibilty on the case that a generator is not fully exhausted and the contextmanager is not cleaned up properly.
A contextmanager must yield a non constant value and not handle cleanup for GeneratorExit.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
A contextmanager must yield a non constant value and not handle cleanup for GeneratorExit.
A contextmanager must yield a non-constant value and not handle cleanup for GeneratorExit.

@@ -0,0 +1,6 @@
Checks for generators that use contextmanagers that don't handle cleanup properly.
Copy link
Member

Choose a reason for hiding this comment

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

(FYI, if you use the new_check suffix instead of feature it will be grouped a little bit more helpfully.)

try_with_yield_nodes = [
try_node
for try_node in node.nodes_of_class(nodes.Try)
if list(try_node.nodes_of_class(nodes.Yield))
Copy link
Member

Choose a reason for hiding this comment

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

Maybe I'm missing something obvious, but it seemed on a first impression that list is more expensive than any in this instance. Or is that not so?

Comment on lines 64 to +66
def test_single_line_with(file1):
with open(file1, encoding="utf-8"): return file1.read() # must not trigger
with open(file1, encoding="utf-8"):
return file1.read() # must not trigger
Copy link
Member

Choose a reason for hiding this comment

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

Would you mind reverting the unrelated formatting changes? As you can tell from the test method names, they're testing edge cases relating to oddly formatted code. We don't want to unintentionally degrade test coverage.

@jacobtylerwalls
Copy link
Member

Not sure if I need to change this here

Good call, let's not block your work on that. If it hasn't been fixed on main yet, please open an issue!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement ✨ Improvement to a component Work in progress
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Warn about @contextlib.contextmanager without try/finally in generator functions
4 participants