From 3fa8ffa73137ae125f94d1f20341735ef2336e06 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Sun, 25 Apr 2021 00:38:40 -1000 Subject: [PATCH] Enable mccabe complexity checks in flake8 (#49616) Co-authored-by: Franck Nijhof --- .pre-commit-config.yaml | 1 + .../components/bluetooth_le_tracker/device_tracker.py | 2 +- homeassistant/components/buienradar/sensor.py | 2 +- homeassistant/components/device_sun_light_trigger/__init__.py | 2 +- homeassistant/components/emulated_hue/hue_api.py | 2 +- homeassistant/components/glances/sensor.py | 2 +- homeassistant/components/hassio/__init__.py | 2 +- homeassistant/components/hdmi_cec/__init__.py | 2 +- homeassistant/components/homeassistant/__init__.py | 2 +- homeassistant/components/homekit/accessories.py | 2 +- homeassistant/components/huawei_lte/config_flow.py | 2 +- homeassistant/components/influxdb/__init__.py | 2 +- homeassistant/components/isy994/services.py | 2 +- homeassistant/components/light/__init__.py | 2 +- homeassistant/components/mqtt/climate.py | 2 +- homeassistant/components/mqtt/discovery.py | 4 +++- homeassistant/components/mqtt/fan.py | 2 +- homeassistant/components/mqtt/light/schema_basic.py | 4 ++-- homeassistant/components/mqtt/light/schema_json.py | 2 +- homeassistant/components/mqtt/light/schema_template.py | 2 +- homeassistant/components/netatmo/sensor.py | 2 +- homeassistant/components/ozw/__init__.py | 2 +- homeassistant/components/plex/media_browser.py | 4 +++- homeassistant/components/plex/server.py | 2 +- homeassistant/components/simplisafe/__init__.py | 2 +- homeassistant/components/sonos/media_player.py | 2 +- homeassistant/components/spotify/media_player.py | 2 +- homeassistant/components/stream/worker.py | 2 +- homeassistant/components/synology_dsm/__init__.py | 2 +- homeassistant/components/systemmonitor/sensor.py | 2 +- homeassistant/components/wink/__init__.py | 2 +- homeassistant/components/xmpp/notify.py | 2 +- homeassistant/components/zwave/__init__.py | 2 +- homeassistant/components/zwave_js/__init__.py | 4 +++- homeassistant/config.py | 2 +- homeassistant/helpers/check_config.py | 4 +++- homeassistant/helpers/condition.py | 2 +- homeassistant/helpers/entity_platform.py | 2 +- homeassistant/helpers/update_coordinator.py | 2 +- requirements_test_pre_commit.txt | 1 + setup.cfg | 1 + tests/components/august/mocks.py | 2 +- 42 files changed, 51 insertions(+), 40 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a99f1d7de33..29a46279f22 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -33,6 +33,7 @@ repos: - pydocstyle==6.0.0 - flake8-comprehensions==3.4.0 - flake8-noqa==1.1.0 + - mccabe==0.6.1 files: ^(homeassistant|script|tests)/.+\.py$ - repo: https://github.com/PyCQA/bandit rev: 1.7.0 diff --git a/homeassistant/components/bluetooth_le_tracker/device_tracker.py b/homeassistant/components/bluetooth_le_tracker/device_tracker.py index 9ac79afde2c..6fb6f2109f1 100644 --- a/homeassistant/components/bluetooth_le_tracker/device_tracker.py +++ b/homeassistant/components/bluetooth_le_tracker/device_tracker.py @@ -46,7 +46,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend( ) -def setup_scanner(hass, config, see, discovery_info=None): +def setup_scanner(hass, config, see, discovery_info=None): # noqa: C901 """Set up the Bluetooth LE Scanner.""" new_devices = {} diff --git a/homeassistant/components/buienradar/sensor.py b/homeassistant/components/buienradar/sensor.py index 170493969f8..5ff15a50978 100644 --- a/homeassistant/components/buienradar/sensor.py +++ b/homeassistant/components/buienradar/sensor.py @@ -271,7 +271,7 @@ class BrSensor(SensorEntity): self.async_write_ha_state() @callback - def _load_data(self, data): + def _load_data(self, data): # noqa: C901 """Load the sensor with relevant data.""" # Find sensor diff --git a/homeassistant/components/device_sun_light_trigger/__init__.py b/homeassistant/components/device_sun_light_trigger/__init__.py index 5ae7e43b19a..cb3c10dae75 100644 --- a/homeassistant/components/device_sun_light_trigger/__init__.py +++ b/homeassistant/components/device_sun_light_trigger/__init__.py @@ -80,7 +80,7 @@ async def async_setup(hass, config): return True -async def activate_automation( +async def activate_automation( # noqa: C901 hass, device_group, light_group, light_profile, disable_turn_off ): """Activate the automation.""" diff --git a/homeassistant/components/emulated_hue/hue_api.py b/homeassistant/components/emulated_hue/hue_api.py index be30de01286..bbd899b559b 100644 --- a/homeassistant/components/emulated_hue/hue_api.py +++ b/homeassistant/components/emulated_hue/hue_api.py @@ -322,7 +322,7 @@ class HueOneLightChangeView(HomeAssistantView): """Initialize the instance of the view.""" self.config = config - async def put(self, request, username, entity_number): + async def put(self, request, username, entity_number): # noqa: C901 """Process a request to set the state of an individual light.""" if not is_local(ip_address(request.remote)): return self.json_message("Only local IPs allowed", HTTP_UNAUTHORIZED) diff --git a/homeassistant/components/glances/sensor.py b/homeassistant/components/glances/sensor.py index bbe045eb232..7e599af414c 100644 --- a/homeassistant/components/glances/sensor.py +++ b/homeassistant/components/glances/sensor.py @@ -132,7 +132,7 @@ class GlancesSensor(SensorEntity): self.unsub_update() self.unsub_update = None - async def async_update(self): + async def async_update(self): # noqa: C901 """Get the latest data from REST API.""" value = self.glances_data.api.data if value is None: diff --git a/homeassistant/components/hassio/__init__.py b/homeassistant/components/hassio/__init__.py index 4889c7c137a..a2e7960972d 100644 --- a/homeassistant/components/hassio/__init__.py +++ b/homeassistant/components/hassio/__init__.py @@ -336,7 +336,7 @@ def get_supervisor_ip(): return os.environ["SUPERVISOR"].partition(":")[0] -async def async_setup(hass: HomeAssistant, config: Config) -> bool: +async def async_setup(hass: HomeAssistant, config: Config) -> bool: # noqa: C901 """Set up the Hass.io component.""" # Check local setup for env in ("HASSIO", "HASSIO_TOKEN"): diff --git a/homeassistant/components/hdmi_cec/__init__.py b/homeassistant/components/hdmi_cec/__init__.py index c7dfd335c32..71826429040 100644 --- a/homeassistant/components/hdmi_cec/__init__.py +++ b/homeassistant/components/hdmi_cec/__init__.py @@ -187,7 +187,7 @@ def parse_mapping(mapping, parents=None): yield (val, pad_physical_address(cur)) -def setup(hass: HomeAssistant, base_config): +def setup(hass: HomeAssistant, base_config): # noqa: C901 """Set up the CEC capability.""" # Parse configuration into a dict of device name to physical address diff --git a/homeassistant/components/homeassistant/__init__.py b/homeassistant/components/homeassistant/__init__.py index f80d3a0efb4..fd7f2207bc7 100644 --- a/homeassistant/components/homeassistant/__init__.py +++ b/homeassistant/components/homeassistant/__init__.py @@ -50,7 +50,7 @@ SCHEMA_RELOAD_CONFIG_ENTRY = vol.All( SHUTDOWN_SERVICES = (SERVICE_HOMEASSISTANT_STOP, SERVICE_HOMEASSISTANT_RESTART) -async def async_setup(hass: ha.HomeAssistant, config: dict) -> bool: +async def async_setup(hass: ha.HomeAssistant, config: dict) -> bool: # noqa: C901 """Set up general services related to Home Assistant.""" async def async_handle_turn_service(service): diff --git a/homeassistant/components/homekit/accessories.py b/homeassistant/components/homekit/accessories.py index 307dbf0e806..3aeaa31faed 100644 --- a/homeassistant/components/homekit/accessories.py +++ b/homeassistant/components/homekit/accessories.py @@ -92,7 +92,7 @@ SWITCH_TYPES = { TYPES = Registry() -def get_accessory(hass, driver, state, aid, config): +def get_accessory(hass, driver, state, aid, config): # noqa: C901 """Take state and return an accessory object if supported.""" if not aid: _LOGGER.warning( diff --git a/homeassistant/components/huawei_lte/config_flow.py b/homeassistant/components/huawei_lte/config_flow.py index c95131308d6..beeeab6e0bb 100644 --- a/homeassistant/components/huawei_lte/config_flow.py +++ b/homeassistant/components/huawei_lte/config_flow.py @@ -101,7 +101,7 @@ class ConfigFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): } return user_input[CONF_URL] in existing_urls - async def async_step_user( + async def async_step_user( # noqa: C901 self, user_input: dict[str, Any] | None = None ) -> FlowResultDict: """Handle user initiated config flow.""" diff --git a/homeassistant/components/influxdb/__init__.py b/homeassistant/components/influxdb/__init__.py index dde10ffca76..bb5cf0173c1 100644 --- a/homeassistant/components/influxdb/__init__.py +++ b/homeassistant/components/influxdb/__init__.py @@ -326,7 +326,7 @@ class InfluxClient: close: Callable[[], None] -def get_influx_connection(conf, test_write=False, test_read=False): +def get_influx_connection(conf, test_write=False, test_read=False): # noqa: C901 """Create the correct influx connection for the API version.""" kwargs = { CONF_TIMEOUT: TIMEOUT, diff --git a/homeassistant/components/isy994/services.py b/homeassistant/components/isy994/services.py index 6f0484e3ff4..023f1022661 100644 --- a/homeassistant/components/isy994/services.py +++ b/homeassistant/components/isy994/services.py @@ -157,7 +157,7 @@ SERVICE_RUN_NETWORK_RESOURCE_SCHEMA = vol.All( @callback -def async_setup_services(hass: HomeAssistant): +def async_setup_services(hass: HomeAssistant): # noqa: C901 """Create and register services for the ISY integration.""" existing_services = hass.services.async_services().get(DOMAIN) if existing_services and any( diff --git a/homeassistant/components/light/__init__.py b/homeassistant/components/light/__init__.py index 0b78ed3672e..dba75b805ad 100644 --- a/homeassistant/components/light/__init__.py +++ b/homeassistant/components/light/__init__.py @@ -242,7 +242,7 @@ def filter_turn_off_params(params): return {k: v for k, v in params.items() if k in (ATTR_TRANSITION, ATTR_FLASH)} -async def async_setup(hass, config): +async def async_setup(hass, config): # noqa: C901 """Expose light control via state machine and services.""" component = hass.data[DOMAIN] = EntityComponent( _LOGGER, DOMAIN, hass, SCAN_INTERVAL diff --git a/homeassistant/components/mqtt/climate.py b/homeassistant/components/mqtt/climate.py index dd766ef2035..da0ed485b72 100644 --- a/homeassistant/components/mqtt/climate.py +++ b/homeassistant/components/mqtt/climate.py @@ -359,7 +359,7 @@ class MqttClimate(MqttEntity, ClimateEntity): tpl.hass = self.hass self._command_templates = command_templates - async def _subscribe_topics(self): + async def _subscribe_topics(self): # noqa: C901 """(Re)Subscribe to topics.""" topics = {} qos = self._config[CONF_QOS] diff --git a/homeassistant/components/mqtt/discovery.py b/homeassistant/components/mqtt/discovery.py index 1d3f5034ff2..3a5a3cb5f87 100644 --- a/homeassistant/components/mqtt/discovery.py +++ b/homeassistant/components/mqtt/discovery.py @@ -79,7 +79,9 @@ class MQTTConfig(dict): """Dummy class to allow adding attributes.""" -async def async_start(hass: HomeAssistant, discovery_topic, config_entry=None) -> bool: +async def async_start( # noqa: C901 + hass: HomeAssistant, discovery_topic, config_entry=None +) -> bool: """Start MQTT Discovery.""" mqtt_integrations = {} diff --git a/homeassistant/components/mqtt/fan.py b/homeassistant/components/mqtt/fan.py index 35393ea819c..bdbe3412539 100644 --- a/homeassistant/components/mqtt/fan.py +++ b/homeassistant/components/mqtt/fan.py @@ -335,7 +335,7 @@ class MqttFan(MqttEntity, FanEntity): tpl.hass = self.hass tpl_dict[key] = tpl.async_render_with_possible_json_value - async def _subscribe_topics(self): + async def _subscribe_topics(self): # noqa: C901 """(Re)Subscribe to topics.""" topics = {} diff --git a/homeassistant/components/mqtt/light/schema_basic.py b/homeassistant/components/mqtt/light/schema_basic.py index 9c4b0f3a3e3..000ab956911 100644 --- a/homeassistant/components/mqtt/light/schema_basic.py +++ b/homeassistant/components/mqtt/light/schema_basic.py @@ -250,7 +250,7 @@ class MqttLight(MqttEntity, LightEntity, RestoreEntity): ) self._optimistic_xy = optimistic or topic[CONF_XY_STATE_TOPIC] is None - async def _subscribe_topics(self): + async def _subscribe_topics(self): # noqa: C901 """(Re)Subscribe to topics.""" topics = {} @@ -579,7 +579,7 @@ class MqttLight(MqttEntity, LightEntity, RestoreEntity): return supported_features - async def async_turn_on(self, **kwargs): + async def async_turn_on(self, **kwargs): # noqa: C901 """Turn the device on. This method is a coroutine. diff --git a/homeassistant/components/mqtt/light/schema_json.py b/homeassistant/components/mqtt/light/schema_json.py index 9940d646a35..5143b92622a 100644 --- a/homeassistant/components/mqtt/light/schema_json.py +++ b/homeassistant/components/mqtt/light/schema_json.py @@ -487,7 +487,7 @@ class MqttLightJson(MqttEntity, LightEntity, RestoreEntity): def _supports_color_mode(self, color_mode): return self.supported_color_modes and color_mode in self.supported_color_modes - async def async_turn_on(self, **kwargs): + async def async_turn_on(self, **kwargs): # noqa: C901 """Turn the device on. This method is a coroutine. diff --git a/homeassistant/components/mqtt/light/schema_template.py b/homeassistant/components/mqtt/light/schema_template.py index 7c0266265db..c5eee7006d6 100644 --- a/homeassistant/components/mqtt/light/schema_template.py +++ b/homeassistant/components/mqtt/light/schema_template.py @@ -142,7 +142,7 @@ class MqttLightTemplate(MqttEntity, LightEntity, RestoreEntity): or self._templates[CONF_STATE_TEMPLATE] is None ) - async def _subscribe_topics(self): + async def _subscribe_topics(self): # noqa: C901 """(Re)Subscribe to topics.""" for tpl in self._templates.values(): if tpl is not None: diff --git a/homeassistant/components/netatmo/sensor.py b/homeassistant/components/netatmo/sensor.py index 4c6facb3eca..380ae1eff69 100644 --- a/homeassistant/components/netatmo/sensor.py +++ b/homeassistant/components/netatmo/sensor.py @@ -333,7 +333,7 @@ class NetatmoSensor(NetatmoBase, SensorEntity): return self._enabled_default @callback - def async_update_callback(self): + def async_update_callback(self): # noqa: C901 """Update the entity's state.""" if self._data is None: if self._state is None: diff --git a/homeassistant/components/ozw/__init__.py b/homeassistant/components/ozw/__init__.py index c484eb4e0c0..f3d827a57ff 100644 --- a/homeassistant/components/ozw/__init__.py +++ b/homeassistant/components/ozw/__init__.py @@ -56,7 +56,7 @@ DATA_DEVICES = "zwave-mqtt-devices" DATA_STOP_MQTT_CLIENT = "ozw_stop_mqtt_client" -async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry): +async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry): # noqa: C901 """Set up ozw from a config entry.""" hass.data.setdefault(DOMAIN, {}) ozw_data = hass.data[DOMAIN][entry.entry_id] = {} diff --git a/homeassistant/components/plex/media_browser.py b/homeassistant/components/plex/media_browser.py index f3f92880c44..e19d86e89ec 100644 --- a/homeassistant/components/plex/media_browser.py +++ b/homeassistant/components/plex/media_browser.py @@ -52,7 +52,9 @@ ITEM_TYPE_MEDIA_CLASS = { _LOGGER = logging.getLogger(__name__) -def browse_media(entity, is_internal, media_content_type=None, media_content_id=None): +def browse_media( # noqa: C901 + entity, is_internal, media_content_type=None, media_content_id=None +): """Implement the websocket media browsing helper.""" def item_payload(item): diff --git a/homeassistant/components/plex/server.py b/homeassistant/components/plex/server.py index d4bd4b09ef2..4dcdda044eb 100644 --- a/homeassistant/components/plex/server.py +++ b/homeassistant/components/plex/server.py @@ -316,7 +316,7 @@ class PlexServer: self.plextv_clients(), ) - async def _async_update_platforms(self): + async def _async_update_platforms(self): # noqa: C901 """Update the platform entities.""" _LOGGER.debug("Updating devices") diff --git a/homeassistant/components/simplisafe/__init__.py b/homeassistant/components/simplisafe/__init__.py index 6324df33117..12c27c3c63c 100644 --- a/homeassistant/components/simplisafe/__init__.py +++ b/homeassistant/components/simplisafe/__init__.py @@ -181,7 +181,7 @@ async def async_setup(hass, config): return True -async def async_setup_entry(hass, config_entry): +async def async_setup_entry(hass, config_entry): # noqa: C901 """Set up SimpliSafe as config entry.""" hass.data[DOMAIN][DATA_LISTENER][config_entry.entry_id] = [] diff --git a/homeassistant/components/sonos/media_player.py b/homeassistant/components/sonos/media_player.py index 8c7b61e96ec..202a72d37ab 100644 --- a/homeassistant/components/sonos/media_player.py +++ b/homeassistant/components/sonos/media_player.py @@ -158,7 +158,7 @@ class SonosData: self.hosts_heartbeat = None -async def async_setup_entry( +async def async_setup_entry( # noqa: C901 hass: HomeAssistant, config_entry: ConfigEntry, async_add_entities: Callable ) -> None: """Set up Sonos from a config entry.""" diff --git a/homeassistant/components/spotify/media_player.py b/homeassistant/components/spotify/media_player.py index 0a291582a30..8beb9733fa2 100644 --- a/homeassistant/components/spotify/media_player.py +++ b/homeassistant/components/spotify/media_player.py @@ -533,7 +533,7 @@ class SpotifyMediaPlayer(MediaPlayerEntity): return response -def build_item_response(spotify, user, payload): +def build_item_response(spotify, user, payload): # noqa: C901 """Create response payload for the provided media query.""" media_content_type = payload["media_content_type"] media_content_id = payload["media_content_id"] diff --git a/homeassistant/components/stream/worker.py b/homeassistant/components/stream/worker.py index cd4528b3088..fb3562c1b53 100644 --- a/homeassistant/components/stream/worker.py +++ b/homeassistant/components/stream/worker.py @@ -122,7 +122,7 @@ class SegmentBuffer: self._stream_buffer.output.close() -def stream_worker(source, options, segment_buffer, quit_event): +def stream_worker(source, options, segment_buffer, quit_event): # noqa: C901 """Handle consuming streams.""" try: diff --git a/homeassistant/components/synology_dsm/__init__.py b/homeassistant/components/synology_dsm/__init__.py index 3c9461f6ca3..74cf8775b1c 100644 --- a/homeassistant/components/synology_dsm/__init__.py +++ b/homeassistant/components/synology_dsm/__init__.py @@ -118,7 +118,7 @@ async def async_setup(hass, config): return True -async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry): +async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry): # noqa: C901 """Set up Synology DSM sensors.""" # Migrate old unique_id diff --git a/homeassistant/components/systemmonitor/sensor.py b/homeassistant/components/systemmonitor/sensor.py index 6d6e898908d..70fd8275bd7 100644 --- a/homeassistant/components/systemmonitor/sensor.py +++ b/homeassistant/components/systemmonitor/sensor.py @@ -365,7 +365,7 @@ class SystemMonitorSensor(SensorEntity): ) -def _update( +def _update( # noqa: C901 type_: str, data: SensorData ) -> tuple[str | None, str | None, datetime.datetime | None]: """Get the latest system information.""" diff --git a/homeassistant/components/wink/__init__.py b/homeassistant/components/wink/__init__.py index 198bddc937b..f11e15670e9 100644 --- a/homeassistant/components/wink/__init__.py +++ b/homeassistant/components/wink/__init__.py @@ -280,7 +280,7 @@ def _request_oauth_completion(hass, config): ) -def setup(hass, config): +def setup(hass, config): # noqa: C901 """Set up the Wink component.""" if hass.data.get(DOMAIN) is None: diff --git a/homeassistant/components/xmpp/notify.py b/homeassistant/components/xmpp/notify.py index 2abd3ffa245..bc5ebf12f75 100644 --- a/homeassistant/components/xmpp/notify.py +++ b/homeassistant/components/xmpp/notify.py @@ -113,7 +113,7 @@ class XmppNotificationService(BaseNotificationService): ) -async def async_send_message( +async def async_send_message( # noqa: C901 sender, password, recipients, diff --git a/homeassistant/components/zwave/__init__.py b/homeassistant/components/zwave/__init__.py index 12ea668dce8..6cf39709aaf 100644 --- a/homeassistant/components/zwave/__init__.py +++ b/homeassistant/components/zwave/__init__.py @@ -392,7 +392,7 @@ async def async_setup(hass, config): return True -async def async_setup_entry(hass, config_entry): +async def async_setup_entry(hass, config_entry): # noqa: C901 """Set up Z-Wave from a config entry. Will automatically load components to support devices found on the network. diff --git a/homeassistant/components/zwave_js/__init__.py b/homeassistant/components/zwave_js/__init__.py index b7d95ab7bc7..7c77105bbea 100644 --- a/homeassistant/components/zwave_js/__init__.py +++ b/homeassistant/components/zwave_js/__init__.py @@ -108,7 +108,9 @@ def register_node_in_dev_reg( return device -async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: +async def async_setup_entry( # noqa: C901 + hass: HomeAssistant, entry: ConfigEntry +) -> bool: """Set up Z-Wave JS from a config entry.""" use_addon = entry.data.get(CONF_USE_ADDON) if use_addon: diff --git a/homeassistant/config.py b/homeassistant/config.py index 958dcea555f..d22df2184f6 100644 --- a/homeassistant/config.py +++ b/homeassistant/config.py @@ -755,7 +755,7 @@ async def merge_packages_config( return config -async def async_process_component_config( +async def async_process_component_config( # noqa: C901 hass: HomeAssistant, config: ConfigType, integration: Integration ) -> ConfigType | None: """Check component configuration and return processed configuration. diff --git a/homeassistant/helpers/check_config.py b/homeassistant/helpers/check_config.py index a486c8bcc14..26e063ae1f2 100644 --- a/homeassistant/helpers/check_config.py +++ b/homeassistant/helpers/check_config.py @@ -63,7 +63,9 @@ class HomeAssistantConfig(OrderedDict): return "\n".join([err.message for err in self.errors]) -async def async_check_ha_config_file(hass: HomeAssistant) -> HomeAssistantConfig: +async def async_check_ha_config_file( # noqa: C901 + hass: HomeAssistant, +) -> HomeAssistantConfig: """Load and check if Home Assistant configuration file is valid. This method is a coroutine. diff --git a/homeassistant/helpers/condition.py b/homeassistant/helpers/condition.py index b6030c61a1c..d1a7c95d16c 100644 --- a/homeassistant/helpers/condition.py +++ b/homeassistant/helpers/condition.py @@ -301,7 +301,7 @@ def numeric_state( ).result() -def async_numeric_state( +def async_numeric_state( # noqa: C901 hass: HomeAssistant, entity: None | str | State, below: float | str | None = None, diff --git a/homeassistant/helpers/entity_platform.py b/homeassistant/helpers/entity_platform.py index abeeb40ca76..e87960db779 100644 --- a/homeassistant/helpers/entity_platform.py +++ b/homeassistant/helpers/entity_platform.py @@ -388,7 +388,7 @@ class EntityPlatform: self.scan_interval, ) - async def _async_add_entity( # type: ignore[no-untyped-def] + async def _async_add_entity( # type: ignore[no-untyped-def] # noqa: C901 self, entity, update_before_add, entity_registry, device_registry ): """Add an entity to the platform.""" diff --git a/homeassistant/helpers/update_coordinator.py b/homeassistant/helpers/update_coordinator.py index 863fa71d43c..f9b97698220 100644 --- a/homeassistant/helpers/update_coordinator.py +++ b/homeassistant/helpers/update_coordinator.py @@ -157,7 +157,7 @@ class DataUpdateCoordinator(Generic[T]): """Refresh data and log errors.""" await self._async_refresh(log_failures=True) - async def _async_refresh( + async def _async_refresh( # noqa: C901 self, log_failures: bool = True, raise_on_auth_failed: bool = False, diff --git a/requirements_test_pre_commit.txt b/requirements_test_pre_commit.txt index 92920c91549..3a146eb425e 100644 --- a/requirements_test_pre_commit.txt +++ b/requirements_test_pre_commit.txt @@ -8,6 +8,7 @@ flake8-docstrings==1.6.0 flake8-noqa==1.1.0 flake8==3.9.1 isort==5.8.0 +mccabe==0.6.1 pycodestyle==2.7.0 pydocstyle==6.0.0 pyflakes==2.3.1 diff --git a/setup.cfg b/setup.cfg index d8569ad2188..3efd58e5ac9 100644 --- a/setup.cfg +++ b/setup.cfg @@ -17,6 +17,7 @@ classifier = [flake8] exclude = .venv,.git,.tox,docs,venv,bin,lib,deps,build +max-complexity = 25 doctests = True # To work with Black # E501: line too long diff --git a/tests/components/august/mocks.py b/tests/components/august/mocks.py index 9a54a708a4f..13d8f18d0d9 100644 --- a/tests/components/august/mocks.py +++ b/tests/components/august/mocks.py @@ -77,7 +77,7 @@ async def _mock_setup_august( return entry -async def _create_august_with_devices( +async def _create_august_with_devices( # noqa: C901 hass, devices, api_call_side_effects=None, activities=None, pubnub=None ): if api_call_side_effects is None: