Skip to content

Conversation

cdce8p
Copy link
Member

@cdce8p cdce8p commented Sep 29, 2025

Followup to #10581

Suggest rewriting conditional expressions

-if not isinstance(expr, nodes.Attribute) or expr.attrname != "__init__": ...
+if not (isinstance(expr, nodes.Attribute) and expr.attrname == "__init__"): ...

I've added the check in the CodeStyle extension. It might even make sense to disable it by default.

@cdce8p cdce8p added this to the 4.0.0 milestone Sep 29, 2025
@cdce8p cdce8p added Enhancement ✨ Improvement to a component Optional Checkers Related to a checked, disabled by default labels Sep 29, 2025
Comment on lines 78 to 85
"R6106": (
"Rewrite conditional expression to '%s'",
"improve-conditionals",
"Rewrite negated if expressions to improve readability.",
{
# "default_enabled": False,
},
),
Copy link
Member Author

Choose a reason for hiding this comment

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

This could probably be improved. Open to suggestions.
We could also change the checker name if someone has a good idea.

Besides that, should the checker be disabled by default even in the optional CodeStyle extension?

Copy link
Member

Choose a reason for hiding this comment

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

Either that or it should be a pylint plugin. I regret including magic-number-comparison because then Ruff implemented it and Ruff does not take the default disable into account and it makes pylint look really opinionated and unreasonable.

Copy link

codecov bot commented Sep 29, 2025

Codecov Report

❌ Patch coverage is 89.69072% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 95.92%. Comparing base (0871a4d) to head (87e5786).
⚠️ Report is 6 commits behind head on main.

Files with missing lines Patch % Lines
pylint/extensions/code_style.py 85.71% 8 Missing ⚠️
pylint/checkers/spelling.py 33.33% 2 Missing ⚠️

❌ Your patch check has failed because the patch coverage (89.69%) is below the target coverage (100.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #10600      +/-   ##
==========================================
- Coverage   95.95%   95.92%   -0.04%     
==========================================
  Files         176      176              
  Lines       19476    19525      +49     
==========================================
+ Hits        18689    18730      +41     
- Misses        787      795       +8     
Files with missing lines Coverage Δ
pylint/checkers/base/name_checker/checker.py 98.72% <100.00%> (ø)
pylint/checkers/classes/class_checker.py 94.01% <100.00%> (ø)
pylint/checkers/dataclass_checker.py 100.00% <100.00%> (ø)
pylint/checkers/design_analysis.py 98.42% <100.00%> (ø)
pylint/checkers/exceptions.py 98.30% <100.00%> (ø)
pylint/checkers/imports.py 94.88% <100.00%> (ø)
...int/checkers/refactoring/recommendation_checker.py 96.96% <100.00%> (ø)
pylint/checkers/refactoring/refactoring_checker.py 98.22% <100.00%> (ø)
pylint/checkers/stdlib.py 96.33% <100.00%> (ø)
pylint/checkers/strings.py 94.29% <100.00%> (ø)
... and 9 more

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

Writing the doc example with animal made me reconsider if the suggestion is always more readable. I guess when there's a double negation not x or not y, then yes, not (x and y) is better for not x or y >= 0 then not (x and y < 0) is slightly better, otherwise I don't know. The primer also point to an especially opinionated check that could be an external plugin. Let us hear from others.

Comment on lines 78 to 85
"R6106": (
"Rewrite conditional expression to '%s'",
"improve-conditionals",
"Rewrite negated if expressions to improve readability.",
{
# "default_enabled": False,
},
),
Copy link
Member

Choose a reason for hiding this comment

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

Either that or it should be a pylint plugin. I regret including magic-number-comparison because then Ruff implemented it and Ruff does not take the default disable into account and it makes pylint look really opinionated and unreasonable.

Comment on lines 1 to 4
def func(expr, node_cls):
# +1:[improve-conditionals]
if not isinstance(expr, node_cls) or expr.attrname != "__init__":
...
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
def func(expr, node_cls):
# +1:[improve-conditionals]
if not isinstance(expr, node_cls) or expr.attrname != "__init__":
...
def is_platypus(animal):
# The platypus is both the only mammal with a beak and without nipples.
# +1:[improve-conditionals]
return animal.is_mammal() and (not animal.has_nipples() or animal.has_beak)

Copy link
Member Author

Choose a reason for hiding this comment

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

Your example wouldn't actually raise the message. Yes, it could be inverted but so far I've chosen not to emit it if we'd need to add not, only if it could be removed / moved before the BoolOp. I.e. it would only be emitted for

# bad
x and (not y or not z)

# good
x and not (y and z)

Copy link
Member

@Pierre-Sassoulas Pierre-Sassoulas Sep 30, 2025

Choose a reason for hiding this comment

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

Ok the checker is a lot less opinionated than I thought then : good.

I had to do some extensive phenology for this one, turn out uniquely identifying an animal by lack of a characteristic is not so easy.

Suggested change
def func(expr, node_cls):
# +1:[improve-conditionals]
if not isinstance(expr, node_cls) or expr.attrname != "__init__":
...
def is_penguin(animal):
# Penguins are the only flightless, kneeless sea birds
# +1:[improve-conditionals]
return animal.is_seabird() and (not animal.can_fly() or not animal.has_visible_knee())

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok the checker is a lot less opinionated than I thought then : good.

I went through all of the warning for Home Assistant. They looked quite good. There was just one common pattern I don't think the checker should emit a warning for.

# is x between 0 and 100
if x > 0 or x < 100:
    ...

Addressed that one in b08beb4

bool(name)
and name[0] == "_"
and (len(name) <= 4 or name[1] != "_" or name[-2:] != "__")
and not (len(name) > 4 and name[:2] == "__" and name[-2:] == "__")
Copy link
Member

Choose a reason for hiding this comment

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

The condition was done with great care about performance here, I'm not sure changing the order without benchmark is advisable.

Copy link
Member Author

Choose a reason for hiding this comment

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

Are they any different though? Let's consider some cases

Returning True

To return True with the "old" code, any one of the conditions had to evaluate to true and or short-circuits the conditional. With the "new" one it's just the inverse. Any one condition has to eval to false and and short-circuits as well. That's fine as all comparisons are inverted itself.

Returning False

With or all conditions had to be checked to make sure none actually returned true. Same with and. It will only return false if all conditions eval to true.

--
Am I missing something here? Tbh I had to think hard about it and even thought they aren't identical for a few minutes. In the end however, they should evaluate almost exactly the same.

--
I reverted the same change to the second check with name[:2] (instead of name[1]) in 7e4bb03.

Copy link
Member

Choose a reason for hiding this comment

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

I looked at it too fast and thought that the prior check for first char is _ was removed, but it's not. We already checked the first character so name[:2] == "__" should stay name[1] == "_". And in this case it become equivalent.

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.

+0.5 for deactivated by default in the code style checker. I invested so much time in the biology involved in the doc example that I now have sunk cost fallacy about it.

@cdce8p cdce8p force-pushed the check-improved-conditionals branch from 840dfbf to 7e4bb03 Compare October 1, 2025 19:23

This comment has been minimized.

Copy link
Member Author

@cdce8p cdce8p left a comment

Choose a reason for hiding this comment

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

I think this check is ready now. Yes, it's a bit opinionated but that could even be a positive thing. In the end it'll be disabled by default in an optional checker.

At last I just want to highlight one of the cases I found in Home Assistant. There aren't a lot of them but sometimes it can be just art 🧑‍🎨

# current
if (
    not isinstance(data, dict)
    or "eventType" not in data
    or data["eventType"] != "changeReport"
    or "eventVersion" not in data
    or data["eventVersion"] != "1"
    or "context" not in data
    or not isinstance(data["context"], dict)
    or "deviceType" not in data["context"]
    or "deviceMac" not in data["context"]
):
    return
# with 'and' instead of 'or' it gets obvious that this might be a great place for match
if not (
    isinstance(data, dict)
    and "eventType" in data
    and data["eventType"] == "changeReport"
    and "eventVersion" in data
    and data["eventVersion"] == "1"
    and "context" in data
    and isinstance(data["context"], dict)
    and "deviceType" in data["context"]
    and "deviceMac" in data["context"]
):
    return
match data:
    case {
        "eventType": "changeReport",
        "eventVersion": "1",
        "context": {"deviceType": _, "deviceMac": _},
    }:
        pass
    case _:
        return

Comment on lines 1 to 4
def func(expr, node_cls):
# +1:[improve-conditionals]
if not isinstance(expr, node_cls) or expr.attrname != "__init__":
...
Copy link
Member Author

Choose a reason for hiding this comment

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

Ok the checker is a lot less opinionated than I thought then : good.

I went through all of the warning for Home Assistant. They looked quite good. There was just one common pattern I don't think the checker should emit a warning for.

# is x between 0 and 100
if x > 0 or x < 100:
    ...

Addressed that one in b08beb4

bool(name)
and name[0] == "_"
and (len(name) <= 4 or name[1] != "_" or name[-2:] != "__")
and not (len(name) > 4 and name[:2] == "__" and name[-2:] == "__")
Copy link
Member Author

Choose a reason for hiding this comment

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

Are they any different though? Let's consider some cases

Returning True

To return True with the "old" code, any one of the conditions had to evaluate to true and or short-circuits the conditional. With the "new" one it's just the inverse. Any one condition has to eval to false and and short-circuits as well. That's fine as all comparisons are inverted itself.

Returning False

With or all conditions had to be checked to make sure none actually returned true. Same with and. It will only return false if all conditions eval to true.

--
Am I missing something here? Tbh I had to think hard about it and even thought they aren't identical for a few minutes. In the end however, they should evaluate almost exactly the same.

--
I reverted the same change to the second check with name[:2] (instead of name[1]) in 7e4bb03.

Copy link
Contributor

github-actions bot commented Oct 2, 2025

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

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

  1. improve-conditionals:
    Rewrite conditional expression to 'not (integration.homekit and 'models' in integration.homekit and integration.homekit['models'])'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/loader.py#L600
  2. improve-conditionals:
    Rewrite conditional expression to 'not (hass and integration_domain)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/loader.py#L1690
  3. improve-conditionals:
    Rewrite conditional expression to 'not (running := current_setup_group.get() and running in _setup_started(hass))'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/setup.py#L707
  4. improve-conditionals:
    Rewrite conditional expression to 'not (context and 'source' in context)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/config_entries.py#L1413
  5. improve-conditionals:
    Rewrite conditional expression to 'not (context and 'source' in context)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/config_entries.py#L1725
  6. improve-conditionals:
    Rewrite conditional expression to 'not (issue.domain == HOMEASSISTANT_DOMAIN and issue_data := issue.data and issue_data.get('issue_type') == ISSUE_UNIQUE_ID_COLLISION)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/config_entries.py#L2727
  7. improve-conditionals:
    Rewrite conditional expression to 'not (context and 'source' in context)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/config_entries.py#L3331
  8. improve-conditionals:
    Rewrite conditional expression to 'not (domain and object_id)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/core.py#L211
  9. improve-conditionals:
    Rewrite conditional expression to 'not (error_path and path_part := error_path[0] in schema)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/data_entry_flow.py#L175
  10. improve-conditionals:
    Rewrite conditional expression to 'not (cur_step['progress_action'] == result.get('progress_action') and cur_step['description_placeholders'] == result.get('description_placeholders'))'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/data_entry_flow.py#L430
  11. improve-conditionals:
    Rewrite conditional expression to 'not (base_exc := exc.cause and isinstance(base_exc, MarkedYAMLError))'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/config.py#L223
  12. improve-conditionals:
    Rewrite conditional expression to 'not (_domain and _domain.strip(' ') == _domain)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/helpers/config_validation.py#L447
  13. improve-conditionals:
    Rewrite conditional expression to 'not (isinstance(value, dict) and value)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/helpers/config_validation.py#L809
  14. improve-conditionals:
    Rewrite conditional expression to 'not (key in breakpoints and run_id in breakpoints[key])'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/helpers/script.py#L2077
  15. improve-conditionals:
    Rewrite conditional expression to 'not (self.config_entry and config_subentry_id in self.config_entry.subentries)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/helpers/entity_platform.py#L709
  16. improve-conditionals:
    Rewrite conditional expression to 'not (DATA_ENTITY_PLATFORM in hass.data and integration_name in hass.data[DATA_ENTITY_PLATFORM])'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/helpers/entity_platform.py#L1267
  17. improve-conditionals:
    Rewrite conditional expression to 'not (country in self.config['countries'] and country in COUNTRIES)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/helpers/selector.py#L630
  18. improve-conditionals:
    Rewrite conditional expression to 'not (source_device_id and 'device_id' in data['changes'])'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/helpers/helper_integration.py#L81
  19. improve-conditionals:
    Rewrite conditional expression to 'not (source_device := device_registry.async_get(source_device_id) and helper_config_entry_id in source_device.config_entries)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/helpers/helper_integration.py#L146
  20. improve-conditionals:
    Rewrite conditional expression to 'not (exposed_entities and exposed_entities['entities'])'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/helpers/llm.py#L482
  21. improve-conditionals:
    Rewrite conditional expression to 'not (llm_context.device_id and async_device_supports_timers(self.hass, llm_context.device_id))'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/helpers/llm.py#L528
  22. improve-conditionals:
    Rewrite conditional expression to 'not (llm_context.device_id and async_device_supports_timers(self.hass, llm_context.device_id))'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/helpers/llm.py#L558
  23. improve-conditionals:
    Rewrite conditional expression to 'not (key in last_variables and last_variables[key] == value)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/helpers/trace.py#L77
  24. improve-conditionals:
    Rewrite conditional expression to 'not (url.scheme in CONFIGURATION_URL_SCHEMES and url.host)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/helpers/device_registry.py#L274
  25. improve-conditionals:
    Rewrite conditional expression to 'not (config_entry_id in config_entries_subentries and config_subentry_id in config_entries_subentries[config_entry_id])'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/helpers/device_registry.py#L1621
  26. improve-conditionals:
    Rewrite conditional expression to 'not (config_entry := hass.config_entries.async_get_entry(config_entry_id) and config_subentry_id in config_entry.subentries)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/helpers/entity_registry.py#L775
  27. improve-conditionals:
    Rewrite conditional expression to 'not (entry.data.get('cloudhook') and 'cloud' in hass.config.components)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/helpers/config_entry_flow.py#L278
  28. improve-conditionals:
    Rewrite conditional expression to 'not (group and ATTR_ENTITY_ID in group.attributes)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/helpers/group.py#L53
  29. improve-conditionals:
    Rewrite conditional expression to 'not (self.hass and self._verified_state_writable)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/helpers/entity.py#L1015
  30. improve-conditionals:
    Rewrite conditional expression to 'not (self.hass and self._verified_state_writable)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/helpers/entity.py#L1022
  31. improve-conditionals:
    Rewrite conditional expression to 'not (self.has_entity_name and device_entry := self.device_entry)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/helpers/entity.py#L1053
  32. improve-conditionals:
    Rewrite conditional expression to 'not (capabilities == entry.capabilities and original_device_class == entry.original_device_class and supported_features == entry.supported_features)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/helpers/entity.py#L1160
  33. improve-conditionals:
    Rewrite conditional expression to 'not (self._on_remove and self._async_unsubscribe_device_updates in self._on_remove)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/helpers/entity.py#L1604
  34. improve-conditionals:
    Rewrite conditional expression to 'not (state.domain == 'sensor' and state.attributes.get(ATTR_DEVICE_CLASS) == SensorDeviceClass.TEMPERATURE)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/helpers/area_registry.py#L549
  35. improve-conditionals:
    Rewrite conditional expression to 'not (state.domain == 'sensor' and state.attributes.get(ATTR_DEVICE_CLASS) == SensorDeviceClass.HUMIDITY)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/helpers/area_registry.py#L563
  36. improve-conditionals:
    Rewrite conditional expression to 'not (exception_filter and exception_filter(err))'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/helpers/recorder.py#L103
  37. improve-conditionals:
    Rewrite conditional expression to 'not (conf_key in self._config and attr in last_state.attributes)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/helpers/trigger_template_entity.py#L237
  38. improve-conditionals:
    Rewrite conditional expression to 'not (args and args[0] in commands)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/scripts/macos/__init__.py#L50
  39. improve-conditionals:
    Rewrite conditional expression to 'not (item.summary == current_item.summary and item.description == current_item.description and item.due == current_item.due)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/habitica/todo.py#L176
  40. improve-conditionals:
    Rewrite conditional expression to 'not (media_type.lower() == 'radio' and source in PLAYABLE_SOURCES)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/onkyo/media_player.py#L335
  41. improve-conditionals:
    Rewrite conditional expression to 'not (self.currently_playing and self.currently_playing.item)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/spotify/media_player.py#L91
  42. improve-conditionals:
    Rewrite conditional expression to 'not (disc_key.version == 1 and isinstance(key := disc_key.key, str))'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/hassio/discovery.py#L61
  43. improve-conditionals:
    Rewrite conditional expression to 'not (entry.source == config_entries.SOURCE_HASSIO and entry.unique_id == uuid)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/hassio/discovery.py#L159
  44. improve-conditionals:
    Rewrite conditional expression to 'not (data.get('event') == 'job' and event_data := data.get('data') and event_data.get('uuid') == job_id.hex)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/hassio/backup.py#L729
  45. improve-conditionals:
    Rewrite conditional expression to 'not (grandchild.name == grandchild_job_name and grandchild.errors and grandchild.reference)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/hassio/backup.py#L760
  46. improve-conditionals:
    Rewrite conditional expression to 'not (addon in panels and panels[addon][ATTR_ENABLE])'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/hassio/addon_panel.py#L55
  47. improve-conditionals:
    Rewrite conditional expression to 'not (self.issue and self.issue.suggestions)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/hassio/repairs.py#L82
  48. improve-conditionals:
    Rewrite conditional expression to 'not (new_timezone == last_timezone and new_country == last_country)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/hassio/__init__.py#L412
  49. improve-conditionals:
    Rewrite conditional expression to 'not (DOMAIN in hass.data and split_entity_id(entity_id)[0] == DEVICE_TRACKER_DOMAIN)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/person/__init__.py#L140
  50. improve-conditionals:
    Rewrite conditional expression to 'not (event.device and event.device.id_string)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/rfxtrx/__init__.py#L184
  51. improve-conditionals:
    Rewrite conditional expression to 'not (entity := component.get_entity(entity_id) and isinstance(entity, CalendarEntity))'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/calendar/trigger.py#L99
  52. improve-conditionals:
    Rewrite conditional expression to 'not (value := obj.get(key) and isinstance(value, datetime.datetime))'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/calendar/__init__.py#L115
  53. improve-conditionals:
    Rewrite conditional expression to 'not (entity := self.component.get_entity(entity_id) and isinstance(entity, CalendarEntity))'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/calendar/__init__.py#L656
  54. improve-conditionals:
    Rewrite conditional expression to 'not (entity.supported_features and entity.supported_features & CalendarEntityFeature.CREATE_EVENT)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/calendar/__init__.py#L735
  55. improve-conditionals:
    Rewrite conditional expression to 'not (entity.supported_features and entity.supported_features & CalendarEntityFeature.DELETE_EVENT)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/calendar/__init__.py#L775
  56. improve-conditionals:
    Rewrite conditional expression to 'not (entity.supported_features and entity.supported_features & CalendarEntityFeature.UPDATE_EVENT)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/calendar/__init__.py#L820
  57. improve-conditionals:
    Rewrite conditional expression to 'not (light_ids == saved_light_ids and exclude_ids == saved_exclude_ids)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/vera/__init__.py#L96
  58. improve-conditionals:
    Rewrite conditional expression to 'not (entry and hasattr(entry, 'runtime_data'))'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/google_sheets/services.py#L73
  59. improve-conditionals:
    Rewrite conditional expression to 'not (self.is_on and kwargs)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/govee_light_local/light.py#L187
  60. improve-conditionals:
    Rewrite conditional expression to 'not (first[CONF_HOST] == second[CONF_HOST] and first[CONF_PORT] == second[CONF_PORT])'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/nut/config_flow.py#L85
  61. improve-conditionals:
    Rewrite conditional expression to 'not (self._speed and self._power)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/bond/fan.py#L97
  62. improve-conditionals:
    Rewrite conditional expression to 'not (identifier[0] == DOMAIN and len(identifier) == 3)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/bond/__init__.py#L128
  63. improve-conditionals:
    Rewrite conditional expression to 'not (hub.bond_id == bond_id and any((device_id == device.device_id for device in hub.devices)))'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/bond/__init__.py#L136
  64. improve-conditionals:
    Rewrite conditional expression to 'not (port == router.port and ssl == router.ssl)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/netgear/__init__.py#L48
  65. improve-conditionals:
    Rewrite conditional expression to 'not (discovery_info.ssdp_location and ATTR_UPNP_MANUFACTURER in discovery_info.upnp and ATTR_UPNP_SERIAL in discovery_info.upnp and ATTR_UPNP_MODEL_NAME in discovery_info.upnp and ATTR_UPNP_MODEL_NUMBER in discovery_info.upnp)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/wilight/config_flow.py#L67
  66. improve-conditionals:
    Rewrite conditional expression to 'not ('motor_state' in self._status and 'position_current' in self._status)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/wilight/cover.py#L93
  67. improve-conditionals:
    Rewrite conditional expression to 'not (configured_by_user := DOMAIN in config and url := config[DOMAIN].get(CONF_URL))'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/go2rtc/__init__.py#L117
  68. improve-conditionals:
    Rewrite conditional expression to 'not (self._cloud.is_logged_in and self._prefs.google_connected and self._cloud.username)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/cloud/google_config.py#L404
  69. improve-conditionals:
    Rewrite conditional expression to 'not (event.data['action'] == 'update' and 'area_id' in event.data['changes'])'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/cloud/google_config.py#L493
  70. improve-conditionals:
    Rewrite conditional expression to 'not (self.enabled and self._cloud.is_logged_in)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/cloud/alexa_config.py#L527
  71. improve-conditionals:
    Rewrite conditional expression to 'not (preset_modes and preset_mode in preset_modes)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/fan/__init__.py#L278
  72. improve-conditionals:
    Rewrite conditional expression to 'not (location_info and is_ipv4_address(location_info.ip))'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/cloudflare/__init__.py#L113
  73. improve-conditionals:
    Rewrite conditional expression to 'not (valid_state and valid_state_numeric)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/group/sensor.py#L447
  74. improve-conditionals:
    Rewrite conditional expression to 'not (description.key in coordinator.data and QSD_LACP_PORTS in coordinator.data[description.key])'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/qnap_qsw/sensor.py#L307
  75. improve-conditionals:
    Rewrite conditional expression to 'not (description.key in coordinator.data and QSD_PORTS in coordinator.data[description.key])'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/qnap_qsw/sensor.py#L327
  76. improve-conditionals:
    Rewrite conditional expression to 'not (self._source.presets and preset_id in self._source.presets)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/russound_rio/media_player.py#L262
  77. improve-conditionals:
    Rewrite conditional expression to 'not (pump_data and pump_data.get(VALUE.DATA))'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/screenlogic/sensor.py#L293
  78. improve-conditionals:
    Rewrite conditional expression to 'not (p_data and p_data.get(VALUE.DATA))'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/screenlogic/binary_sensor.py#L216
  79. improve-conditionals:
    Rewrite conditional expression to 'not (entry := hass.config_entries.async_get_entry(entry_id) and entry.domain == validated_config[CONF_DOMAIN])'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/device_automation/helpers.py#L98
  80. improve-conditionals:
    Rewrite conditional expression to 'not (hs_color and self.supported_color_modes and ColorMode.HS in self.supported_color_modes)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/yeelight/light.py#L629
  81. improve-conditionals:
    Rewrite conditional expression to 'not (rgb and self.supported_color_modes and ColorMode.RGB in self.supported_color_modes)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/yeelight/light.py#L654
  82. improve-conditionals:
    Rewrite conditional expression to 'not (temp_in_k and self.supported_color_modes and ColorMode.COLOR_TEMP in self.supported_color_modes)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/yeelight/light.py#L679
  83. improve-conditionals:
    Rewrite conditional expression to 'not (int(self._get_property('color_mode')) == 1 and self.hs_color)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/yeelight/light.py#L710
  84. improve-conditionals:
    Rewrite conditional expression to 'not (current_entry and host == urlparse(current_entry['location']).hostname)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/yeelight/scanner.py#L198
  85. improve-conditionals:
    Rewrite conditional expression to 'not (CONF_PRODUCT_NAME in discovery_info.properties and CONF_PRODUCT_TYPE in discovery_info.properties and CONF_SERIAL in discovery_info.properties)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/homewizard/config_flow.py#L127
  86. improve-conditionals:
    Rewrite conditional expression to 'not (len(platform_split) >= 2 and platform_split[1] in TRIGGERS)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/webostv/trigger.py#L28
  87. improve-conditionals:
    Rewrite conditional expression to 'not (self.state == MediaPlayerState.OFF and self._supported_features)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/webostv/media_player.py#L249
  88. improve-conditionals:
    Rewrite conditional expression to 'not (self.assistant and language == self.language)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/google_assistant_sdk/__init__.py#L125
  89. improve-conditionals:
    Rewrite conditional expression to 'not (status.user and status.user.username)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/geocaching/config_flow.py#L51
  90. improve-conditionals:
    Rewrite conditional expression to 'not (bucket and key)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/minio/minio_helper.py#L204
  91. improve-conditionals:
    Rewrite conditional expression to 'not (CONF_TOKEN_EXPIRY in self._entry.data and CONF_ACCESS_TOKEN in self._entry.data)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/flick_electric/__init__.py#L114
  92. improve-conditionals:
    Rewrite conditional expression to 'not (self.selected_region and user_input[CONF_REGION] == self.selected_region['regionId'])'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/ukraine_alarm/config_flow.py#L100
  93. improve-conditionals:
    Rewrite conditional expression to 'not (new_state == self.state and img == self.entity_picture)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/buienradar/sensor.py#L830
  94. improve-conditionals:
    Rewrite conditional expression to 'not (new_state == self.state and img == self.entity_picture)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/buienradar/sensor.py#L876
  95. improve-conditionals:
    Rewrite conditional expression to 'not (current_source and current_source in self._sources)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/control4/media_player.py#L285
  96. improve-conditionals:
    Rewrite conditional expression to 'not (current_source and current_source in self._sources)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/control4/media_player.py#L298
  97. improve-conditionals:
    Rewrite conditional expression to 'not (self._char_battery and self._char_low_battery)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/homekit/accessories.py#L592
  98. improve-conditionals:
    Rewrite conditional expression to 'not (self.support_select_source and self.sources)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/homekit/type_remotes.py#L184
  99. improve-conditionals:
    Rewrite conditional expression to 'not (value >= 30 and self._supports_stop)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/homekit/type_covers.py#L416
  100. improve-conditionals:
    Rewrite conditional expression to 'not (self.char_speed and CHAR_ROTATION_SPEED in char_values)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/homekit/type_fans.py#L180
  101. improve-conditionals:
    Rewrite conditional expression to 'not (config and DOMAIN in config)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/homekit/__init__.py#L519
  102. improve-conditionals:
    Rewrite conditional expression to 'not (identifier in entry.identifiers and connection in entry.connections)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/homekit/__init__.py#L981
  103. improve-conditionals:
    Rewrite conditional expression to 'not (entry := hass.config_entries.async_get_entry(entry_id) and entry_data := getattr(entry, 'runtime_data', None) and secret and entry_data.pairing_qr_secret and secret == entry_data.pairing_qr_secret)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/homekit/__init__.py#L1224
  104. improve-conditionals:
    Rewrite conditional expression to 'not (messages and messages[-1]['role'] == 'user')'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/anthropic/entity.py#L89
  105. improve-conditionals:
    Rewrite conditional expression to 'not (messages and messages[-1]['role'] == 'user')'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/anthropic/entity.py#L105
  106. improve-conditionals:
    Rewrite conditional expression to 'not (messages and messages[-1]['role'] == 'assistant')'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/anthropic/entity.py#L123
  107. improve-conditionals:
    Rewrite conditional expression to 'not (data and 'status' in data)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/fireservicerota/switch.py#L142
  108. improve-conditionals:
    Rewrite conditional expression to 'not (data and 'body' in data)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/fireservicerota/sensor.py#L118
  109. improve-conditionals:
    Rewrite conditional expression to 'not (self.data and Attribute.MAC_ADDRESS in self.data)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/aprilaire/coordinator.py#L122
  110. improve-conditionals:
    Rewrite conditional expression to 'not (data and Attribute.MAC_ADDRESS in data)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/aprilaire/coordinator.py#L129
  111. improve-conditionals:
    Rewrite conditional expression to 'not (self.data and Attribute.THERMOSTAT_MODES in self.data)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/aprilaire/coordinator.py#L135
  112. improve-conditionals:
    Rewrite conditional expression to 'not (self.data and Attribute.INDOOR_TEMPERATURE_CONTROLLING_SENSOR_STATUS in self.data)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/aprilaire/coordinator.py#L143
  113. improve-conditionals:
    Rewrite conditional expression to 'not (hass.config.external_url and hass.config.internal_url)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/media_player/browse_media.py#L87
  114. improve-conditionals:
    Rewrite conditional expression to 'not (search_response and entity_response := cast(SearchMedia, search_response.get(target_entity_id)) and results := entity_response.result)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/media_player/intent.py#L368
  115. improve-conditionals:
    Rewrite conditional expression to 'not (options and option in options)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/select/__init__.py#L172
  116. improve-conditionals:
    Rewrite conditional expression to 'not (isinstance(old, HomeAssistantScene) and old.from_service)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/homeassistant/scene.py#L263
  117. improve-conditionals:
    Rewrite conditional expression to 'not ('should_expose' in settings and settings['should_expose'])'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/homeassistant/exposed_entities.py#L449
  118. improve-conditionals:
    Rewrite conditional expression to 'not (self.__code_format_cmp and self.code_format == self.__code_format_cmp.pattern)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/lock/__init__.py#L170
  119. improve-conditionals:
    Rewrite conditional expression to 'not (self._is_new_entity and wrapped_switch := registry.async_get(self._switch_entity_id))'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/switch_as_x/entity.py#L104
  120. improve-conditionals:
    Rewrite conditional expression to 'not (self._volume.level and self._volume.level.level)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/bang_olufsen/media_player.py#L841
  121. improve-conditionals:
    Rewrite conditional expression to 'not (unique_id and unique_id.count(':') == 7)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/deconz/util.py#L18
  122. improve-conditionals:
    Rewrite conditional expression to 'not (device.model in REMOTES and trigger in REMOTES[device.model])'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/deconz/device_trigger.py#L715
  123. improve-conditionals:
    Rewrite conditional expression to 'not (self.preset_modes and preset_mode in self.preset_modes)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/comfoconnect/fan.py#L170
  124. improve-conditionals:
    Rewrite conditional expression to 'not (set(sensor_names).issubset(set(self._sensors)) and sensor_names)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/ecobee/climate.py#L871
  125. improve-conditionals:
    Rewrite conditional expression to 'not (job and job.progress.print_time_left and _is_printer_printing(self.coordinator.data['printer']))'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/octoprint/sensor.py#L180
  126. improve-conditionals:
    Rewrite conditional expression to 'not (job and job.progress.print_time and _is_printer_printing(self.coordinator.data['printer']))'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/octoprint/sensor.py#L210
  127. improve-conditionals:
    Rewrite conditional expression to 'not (camera_info and camera_info.enabled)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/octoprint/camera.py#L35
  128. improve-conditionals:
    Rewrite conditional expression to 'not (host.api.port == config_entry.data[CONF_PORT] and host.api.use_https == config_entry.data[CONF_USE_HTTPS] and host.api.supported(None, 'privacy_mode') == config_entry.data.get(CONF_SUPPORTS_PRIVACY_MODE) and host.api.baichuan.port == config_entry.data.get(CONF_BC_PORT) and host.api.baichuan_only == config_entry.data.get(CONF_BC_ONLY))'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/reolink/__init__.py#L106
  129. improve-conditionals:
    Rewrite conditional expression to 'not (host.api.supported(int(ch), 'replay') and host.api.hdd_info)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/reolink/media_source.py#L209
  130. improve-conditionals:
    Rewrite conditional expression to 'not (device and device.model in DEVICES and trigger in DEVICES[device.model])'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/netatmo/device_trigger.py#L84
  131. improve-conditionals:
    Rewrite conditional expression to 'not (item.identifier and '/' in item.identifier)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/netatmo/media_source.py#L148
  132. improve-conditionals:
    Rewrite conditional expression to 'not ('updateDataSet' in data and 'commonName' in data and self.data.agreement.display_common_name == data['commonName'])'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/toon/coordinator.py#L125
  133. improve-conditionals:
    Rewrite conditional expression to 'not (model := props.get(HOMEKIT_MODEL_LOWER) or props.get(HOMEKIT_MODEL_UPPER) and isinstance(model, str))'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/zeroconf/discovery.py#L125
  134. improve-conditionals:
    Rewrite conditional expression to 'not (flume_devices and flume_devices.device_list)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/flume/config_flow.py#L80
  135. improve-conditionals:
    Rewrite conditional expression to 'not (notification.get('device_id') and notification.get('extra') and 'event_rule_name' in notification['extra'])'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/flume/coordinator.py#L146
  136. improve-conditionals:
    Rewrite conditional expression to 'not (isinstance(slot, int) and 0 <= slot <= 255)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/yalexs_ble/config_flow.py#L53
  137. improve-conditionals:
    Rewrite conditional expression to 'not (validated_config.key == entry.data[CONF_KEY] and validated_config.slot == entry.data[CONF_SLOT])'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/yalexs_ble/__init__.py#L105
  138. improve-conditionals:
    Rewrite conditional expression to 'not (hasattr(self.config_entry, 'runtime_data') and self.config_entry.runtime_data)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/keenetic_ndms2/config_flow.py#L170
  139. improve-conditionals:
    Rewrite conditional expression to 'not (os.path.isdir(model_dir) and os.path.isdir(checkpoint) and os.path.exists(pipeline_config) and os.path.exists(labels))'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/tensorflow/image_processing.py#L143
  140. improve-conditionals:
    Rewrite conditional expression to 'not (matching_item and matching_item.uid)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/todo/intent.py#L128
  141. improve-conditionals:
    Rewrite conditional expression to 'not (supported_features and supported_features & desc.required_feature)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/todo/__init__.py#L113
  142. improve-conditionals:
    Rewrite conditional expression to 'not (entity_id := msg[CONF_ENTITY_ID] and entity := hass.data[DATA_COMPONENT].get_entity(entity_id) and isinstance(entity, TodoListEntity))'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/todo/__init__.py#L386
  143. improve-conditionals:
    Rewrite conditional expression to 'not (entity.supported_features and entity.supported_features & TodoListEntityFeature.MOVE_TODO_ITEM)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/todo/__init__.py#L425
  144. improve-conditionals:
    Rewrite conditional expression to 'not (found and found.uid)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/todo/__init__.py#L508
  145. improve-conditionals:
    Rewrite conditional expression to 'not (self._trip and self._trip.trip_id == trip_id)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/gtfs/sensor.py#L617
  146. improve-conditionals:
    Rewrite conditional expression to 'not (self._route and self._route.route_id == route_id)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/gtfs/sensor.py#L622
  147. improve-conditionals:
    Rewrite conditional expression to 'not (key in self._attributes and self._attributes[key] == self._route.route_id)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/gtfs/sensor.py#L750
  148. improve-conditionals:
    Rewrite conditional expression to 'not (key in self._attributes and self._attributes[key] == self._trip.trip_id)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/gtfs/sensor.py#L762
  149. improve-conditionals:
    Rewrite conditional expression to 'not (state and state.state in self.options)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/input_select/__init__.py#L290
  150. improve-conditionals:
    Rewrite conditional expression to 'not (LightSchema.CONF_INDIVIDUAL_COLORS in config and color in config[LightSchema.CONF_INDIVIDUAL_COLORS])'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/knx/light.py#L97
  151. improve-conditionals:
    Rewrite conditional expression to 'not (_rgbw and any(_rgbw))'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/knx/light.py#L538
  152. improve-conditionals:
    Rewrite conditional expression to 'not (_rgb and any(_rgb))'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/knx/light.py#L544
  153. improve-conditionals:
    Rewrite conditional expression to 'not (_conf and DOMAIN in _conf)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/knx/__init__.py#L110
  154. improve-conditionals:
    Rewrite conditional expression to 'not (platform in self.data['entities'] and unique_id in self.data['entities'][platform])'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/knx/storage/config_store.py#L138
  155. improve-conditionals:
    Rewrite conditional expression to 'not (isinstance(res, dict) and RESULT in res and isinstance(json := res[RESULT], dict) and status := json.get(STATUS))'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/iotty/coordinator.py#L106
  156. improve-conditionals:
    Rewrite conditional expression to 'not (entry and modem := entry.runtime_data.modem.token)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/netgear_lte/services.py#L58
  157. improve-conditionals:
    Rewrite conditional expression to 'not (available and self.is_on)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/amcrest/camera.py#L182
  158. improve-conditionals:
    Rewrite conditional expression to 'not (cloud_username and cloud_password and cloud_country)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/xiaomi_miio/config_flow.py#L78
  159. improve-conditionals:
    Rewrite conditional expression to 'not (name and self.host and self.mac)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/xiaomi_miio/config_flow.py#L161
  160. improve-conditionals:
    Rewrite conditional expression to 'not (cloud_username and cloud_password and cloud_country)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/xiaomi_miio/config_flow.py#L224
  161. improve-conditionals:
    Rewrite conditional expression to 'not (hasattr(self._node, 'status_events') and hasattr(self._node, 'isy'))'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/isy994/button.py#L118
  162. improve-conditionals:
    Rewrite conditional expression to 'not (isy_conf and ISY_CONF_NAME in isy_conf and isy_conf[ISY_CONF_NAME])'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/isy994/config_flow.py#L122
  163. improve-conditionals:
    Rewrite conditional expression to 'not (status and status.protocol == PROTO_PROGRAM)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/isy994/helpers.py#L407
  164. improve-conditionals:
    Rewrite conditional expression to 'not (actions and actions.protocol == PROTO_PROGRAM)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/isy994/helpers.py#L417
  165. improve-conditionals:
    Rewrite conditional expression to 'not (_type in self._events and _device_id == self.device.device_id)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/point/binary_sensor.py#L108
  166. improve-conditionals:
    Rewrite conditional expression to 'not (sensor_data[description.key] == 0 and device.api.type in {'RM4PRO', 'RM4MINI'})'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/broadlink/sensor.py#L120
  167. improve-conditionals:
    Rewrite conditional expression to 'not (mime_type := asset.original_mime_type and mime_type.startswith(('image/', 'video/')))'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/immich/media_source.py#L243
  168. improve-conditionals:
    Rewrite conditional expression to 'not (params and light.is_on)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/light/__init__.py#L454
  169. improve-conditionals:
    Rewrite conditional expression to 'not (state_on and params)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/light/__init__.py#L825
  170. improve-conditionals:
    Rewrite conditional expression to 'not (isinstance(option, int) and 0 <= option < len(self._attr_options))'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/sonos/select.py#L118
  171. improve-conditionals:
    Rewrite conditional expression to 'not (container_ids and match := re.search('FV:2,(\d+)', container_ids))'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/sonos/favorites.py#L75
  172. improve-conditionals:
    Rewrite conditional expression to 'not (CONF_API_VERSION in entry.data and conf_api_version == supported_api_version)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/hue/migration.py#L61
  173. improve-conditionals:
    Rewrite conditional expression to 'not (zigbee and zigbee.mac_address)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/hue/migration.py#L100
  174. improve-conditionals:
    Rewrite conditional expression to 'not (entity_id and entity_entry := entity_registry.async_get(entity_id))'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/tuya/switch.py#L958
  175. improve-conditionals:
    Rewrite conditional expression to 'not (new_config and DOMAIN in new_config)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/intent_script/__init__.py#L82
  176. improve-conditionals:
    Rewrite conditional expression to 'not (vid == vid.upper() and pid == pid.upper() and serial_number == serial_number.lower() and manufacturer == manufacturer.lower() and description == description.lower())'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/usb/__init__.py#L112
  177. improve-conditionals:
    Rewrite conditional expression to 'not (time_fired_ts and shared_data)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/usage_prediction/common_control.py#L128
  178. improve-conditionals:
    Rewrite conditional expression to 'not (description.capability_ignore_list and any((all((capability in device.status[MAIN] for capability in capability_list)) for capability_list in description.capability_ignore_list)))'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/smartthings/sensor.py#L1143
  179. improve-conditionals:
    Rewrite conditional expression to 'not (capability in KEEP_CAPABILITY_QUIRK and KEEP_CAPABILITY_QUIRKcapability)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/smartthings/__init__.py#L552
  180. improve-conditionals:
    Rewrite conditional expression to 'not (start_time and ((end_time or dt_util.utcnow()) - start_time).days > 1)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/recorder/util.py#L165
  181. improve-conditionals:
    Rewrite conditional expression to 'not (end_time and end_time[0])'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/recorder/util.py#L211
  182. improve-conditionals:
    Rewrite conditional expression to 'not (start.minute == 0 and start.second == 0 and start.microsecond == 0)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/recorder/statistics.py#L2510
  183. improve-conditionals:
    Rewrite conditional expression to 'not (metadata['source'] and metadata['source'] == DOMAIN)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/recorder/statistics.py#L2544
  184. improve-conditionals:
    Rewrite conditional expression to 'not (metadata['source'] and metadata['source'] == domain)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/recorder/statistics.py#L2566
  185. improve-conditionals:
    Rewrite conditional expression to 'not (self.schema_version and self.schema_version == SCHEMA_VERSION)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/recorder/core.py#L1495
  186. improve-conditionals:
    Rewrite conditional expression to 'old_metadata['mean_type'] == new_metadata['mean_type'] and old_metadata['has_sum'] == new_metadata['has_sum'] and old_metadata['name'] == new_metadata['name'] and old_metadata['unit_of_measurement'] == new_metadata['unit_of_measurement']'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/recorder/table_managers/statistics_meta.py#L205
  187. improve-conditionals:
    Rewrite conditional expression to 'not (start == duplicate.start and metadata_id == duplicate.metadata_id)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/recorder/auto_repairs/statistics/duplicates.py#L102
  188. improve-conditionals:
    Rewrite conditional expression to 'not (include_start_time_state and run_start_ts)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/recorder/history/modern.py#L183
  189. improve-conditionals:
    Rewrite conditional expression to 'not (entity_id_to_metadata_id := instance.states_meta_manager.get_many(entity_ids, session, False) and possible_metadata_ids := extract_metadata_ids(entity_id_to_metadata_id))'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/recorder/history/modern.py#L242
  190. improve-conditionals:
    Rewrite conditional expression to 'not (include_start_time_state and run_start_ts)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/recorder/history/modern.py#L413
  191. improve-conditionals:
    Rewrite conditional expression to 'not (isinstance(plant_info, dict) and 'data' in plant_info)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/growatt_server/config_flow.py#L205
  192. improve-conditionals:
    Rewrite conditional expression to 'not (plant_info and 'data' in plant_info and plant_info['data'])'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/growatt_server/__init__.py#L61
  193. improve-conditionals:
    Rewrite conditional expression to 'not (isinstance(meter['serviceType'], str) and meter['serviceType'] in _SUPPORTED_METER_TYPES)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/duke_energy/coordinator.py#L82
  194. improve-conditionals:
    Rewrite conditional expression to 'not (self._manufacturer and self._manufacturer.lower().startswith('samsung'))'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/samsungtv/config_flow.py#L448
  195. improve-conditionals:
    Rewrite conditional expression to 'not (len(platform_split) >= 2 and platform_split[1] in TRIGGERS)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/samsungtv/trigger.py#L26
  196. improve-conditionals:
    Rewrite conditional expression to 'not (entry.data.get(CONF_TOKEN) and entry.data.get(CONF_SESSION_ID))'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/samsungtv/__init__.py#L121
  197. improve-conditionals:
    Rewrite conditional expression to 'not (hasattr(platform, 'async_pre_backup') and hasattr(platform, 'async_post_backup'))'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/backup/manager.py#L414
  198. improve-conditionals:
    Rewrite conditional expression to 'not (password and backup.protected)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/backup/http.py#L85
  199. improve-conditionals:
    Rewrite conditional expression to 'not (self._outdoor_temp_sensor and self._indoor_temp_sensor and self._indoor_humidity_sensor and self._calib_factor)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/mold_indicator/sensor.py#L190
  200. improve-conditionals:
    Rewrite conditional expression to 'not (len(platform_split) >= 2 and platform_split[1] in TRIGGERS)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/lg_netcast/trigger.py#L26
  201. improve-conditionals:
    Rewrite conditional expression to 'not (from_dt and to_dt)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/openuv/coordinator.py#L96
  202. improve-conditionals:
    Rewrite conditional expression to 'not (cache and cache['username'] == self._client_id)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/evohome/storage.py#L81
  203. improve-conditionals:
    Rewrite conditional expression to 'not (api_data and api_data.sensors and any(api_data.availability.values()))'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/pvpc_hourly_pricing/coordinator.py#L64
  204. improve-conditionals:
    Rewrite conditional expression to 'not (parsed and parsed.data.get('modelName') in SUPPORTED_MODEL_TYPES)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/switchbot/config_flow.py#L106
  205. improve-conditionals:
    Rewrite conditional expression to 'not (last_state and ATTR_CURRENT_POSITION in last_state.attributes)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/switchbot/cover.py#L71
  206. improve-conditionals:
    Rewrite conditional expression to 'not (last_state and ATTR_CURRENT_TILT_POSITION in last_state.attributes)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/switchbot/cover.py#L158
  207. improve-conditionals:
    Rewrite conditional expression to 'not (last_state and ATTR_CURRENT_POSITION in last_state.attributes)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/switchbot/cover.py#L240
  208. improve-conditionals:
    Rewrite conditional expression to 'not (NOTIFY_SERVICES in hass.data and integration_name in hass.data[NOTIFY_SERVICES])'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/notify/legacy.py#L201
  209. improve-conditionals:
    Rewrite conditional expression to 'not (state := hass.states.get(call.data[ATTR_ENTITY_ID]) and entity := er.async_get(hass).async_get(call.data[ATTR_ENTITY_ID]) and entity.config_entry_id)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/bring/services.py#L64
  210. improve-conditionals:
    Rewrite conditional expression to 'not (SCRIPT_BREAKPOINT_HIT in hass.data.get(DATA_DISPATCHER, {}) and hass.data[DATA_DISPATCHER][SCRIPT_BREAKPOINT_HIT])'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/trace/websocket_api.py#L150
  211. improve-conditionals:
    Rewrite conditional expression to 'not (SCRIPT_BREAKPOINT_HIT in hass.data.get(DATA_DISPATCHER, {}) and hass.data[DATA_DISPATCHER][SCRIPT_BREAKPOINT_HIT])'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/trace/websocket_api.py#L239
  212. improve-conditionals:
    Rewrite conditional expression to 'not (key in old_attributes and old_attributes[key] == value)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/websocket_api/messages.py#L243
  213. improve-conditionals:
    Rewrite conditional expression to 'not (ready_future := self._ready_future and queue_size := len(self._message_queue))'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/websocket_api/http.py#L256
  214. improve-conditionals:
    Rewrite conditional expression to 'not (self._attr_hvac_mode == HVACMode.FAN_ONLY and fan_mode == FAN_AUTO)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/hisense_aehw4a1/climate.py#L253
  215. improve-conditionals:
    Rewrite conditional expression to 'not (default_unit := self.entity_description.native_unit_of_measurement and state := self.device.states.get(self.entity_description.key) and state.value)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/overkiz/sensor.py#L580
  216. improve-conditionals:
    Rewrite conditional expression to 'not (is_moving and current_closure and target_closure)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/overkiz/cover/vertical_cover.py#L122
  217. improve-conditionals:
    Rewrite conditional expression to 'not (is_moving and current_closure and target_closure)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/overkiz/cover/vertical_cover.py#L138
  218. improve-conditionals:
    Rewrite conditional expression to 'not (is_moving and current_closure and target_closure)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/overkiz/cover/awning.py#L84
  219. improve-conditionals:
    Rewrite conditional expression to 'not (is_moving and current_closure and target_closure)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/overkiz/cover/awning.py#L100
  220. improve-conditionals:
    Rewrite conditional expression to 'not (data and isinstance(data.get('time_series'), list))'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/tesla_fleet/coordinator.py#L250
  221. improve-conditionals:
    Rewrite conditional expression to 'not (current_config.enabled and current_config.options.webhook_url in self.webhook_urls and current_config.options.json_payload == json.loads(JSON_PAYLOAD) and current_config.types == REGISTERED_NOTIFICATIONS)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/overseerr/__init__.py#L136
  222. improve-conditionals:
    Rewrite conditional expression to 'not (request_id and self._validate_request_id(request_id))'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/configurator/__init__.py#L246
  223. improve-conditionals:
    Rewrite conditional expression to 'not (discovery_info.subscribed_topic == DISCOVERY_TOPIC and discovery_info.payload)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/drop_connect/config_flow.py#L43
  224. improve-conditionals:
    Rewrite conditional expression to 'not (self.__pattern_cmp and self.pattern == self.__pattern_cmp.pattern)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/text/__init__.py#L214
  225. improve-conditionals:
    Rewrite conditional expression to 'not (result and 'Items' in result and len(result['Items']) >= 1)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/jellyfin/browse_media.py#L148
  226. improve-conditionals:
    Rewrite conditional expression to 'not (map_cap := self._capability.map and position_commands := map_cap.position.get)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/ecovacs/vacuum.py#L380
  227. improve-conditionals:
    Rewrite conditional expression to 'not (auth_resp and client.ResponseOK(auth_resp))'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/hyperion/config_flow.py#L140
  228. improve-conditionals:
    Rewrite conditional expression to 'not (img_data and img_data.startswith(IMAGE_STREAM_JPG_SENTINEL))'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/hyperion/camera.py#L159
  229. improve-conditionals:
    Rewrite conditional expression to 'not (await hyperion_client.async_client_switch_instance() and client.ServerInfoResponseOK(await hyperion_client.async_get_serverinfo()))'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/hyperion/__init__.py#L177
  230. improve-conditionals:
    Rewrite conditional expression to 'not (response and hyperion_const.KEY_DATA in response)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/hyperion/__init__.py#L193
  231. improve-conditionals:
    Rewrite conditional expression to 'not (self.voices and self.models)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/elevenlabs/config_flow.py#L121
  232. improve-conditionals:
    Rewrite conditional expression to 'not (self._coil_temporary_lux and self._coil_temporary_lux.reverse_mappings)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/nibe_heatpump/water_heater.py#L112
  233. improve-conditionals:
    Rewrite conditional expression to 'not (search_result and 'items' in search_result[0])'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/picnic/services.py#L84
  234. improve-conditionals:
    Rewrite conditional expression to 'not (accessory := entity_map.aid_or_none(self._aid) and accessory.services.iid_or_none(self._iid))'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/homekit_controller/entity.py#L65
  235. improve-conditionals:
    Rewrite conditional expression to 'not (device and legacy_serial_identifier in device.identifiers)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/homekit_controller/connection.py#L589
  236. improve-conditionals:
    Rewrite conditional expression to 'not ('inputEvent' in block.sensor_ids and 'inputEventCnt' in block.sensor_ids)'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/shelly/utils.py#L247
  237. improve-conditionals:
    Rewrite conditional expression to 'not (len(mac) == 12 and all((char in '0123456789abcdefABCDEF' for char in mac)))'
    https://github.com/home-assistant/core/blob/ee4a1de5660f930f37119f7d7225838b628bb7c7/homeassistant/components/shelly/utils.py#L560
  238. improve-conditionals...

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

This comment was generated for commit 87e5786

@@ -0,0 +1,3 @@
Add :ref:`improve-conditionals` check to the Code Style extension.
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
Add :ref:`improve-conditionals` check to the Code Style extension.
Add :ref:`improve-conditionals` check to the Code Style extension to suggest `not(x and y)` instead of `not x or not y` in order to facilitate the detection of match case refactors. The code style extension must be enabled and `improve-conditionals` itself needs to be explicitely enabled.

),
"R6106": (
"Rewrite conditional expression to '%s'",
"improve-conditionals",
Copy link
Member

Choose a reason for hiding this comment

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

The name is a little vague. What about consider-factorizing-not, 'or-with-double-negation'... ? I'm on mobile but asking a llm about it might give the least surprising name for it.

@Pierre-Sassoulas
Copy link
Member

The exemple you give does make sense. What if we were raising only strictly above 2 negated conditions ? It's not the same purpose than the initial idea but it would make thé check a lot less opinionated

@Pierre-Sassoulas
Copy link
Member

Pierre-Sassoulas commented Oct 2, 2025

Or say we add an option for the threshold of negated conditions, and activate the message by default with a value of 4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement ✨ Improvement to a component Optional Checkers Related to a checked, disabled by default
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants