mirror of
				https://github.com/esphome/esphome.git
				synced 2025-10-30 22:53:59 +00:00 
			
		
		
		
	[ruff] Enable SIM rules and fix code simplification violations (#9872)
This commit is contained in:
		| @@ -243,10 +243,7 @@ def _final_validate(_): | ||||
|  | ||||
|  | ||||
| def use_legacy(): | ||||
|     if CORE.using_esp_idf: | ||||
|         if not _use_legacy_driver: | ||||
|             return False | ||||
|     return True | ||||
|     return not (CORE.using_esp_idf and not _use_legacy_driver) | ||||
|  | ||||
|  | ||||
| FINAL_VALIDATE_SCHEMA = _final_validate | ||||
|   | ||||
| @@ -44,9 +44,8 @@ PDM_VARIANTS = [esp32.const.VARIANT_ESP32, esp32.const.VARIANT_ESP32S3] | ||||
| def _validate_esp32_variant(config): | ||||
|     variant = esp32.get_esp32_variant() | ||||
|     if config[CONF_ADC_TYPE] == "external": | ||||
|         if config[CONF_PDM]: | ||||
|             if variant not in PDM_VARIANTS: | ||||
|                 raise cv.Invalid(f"{variant} does not support PDM") | ||||
|         if config[CONF_PDM] and variant not in PDM_VARIANTS: | ||||
|             raise cv.Invalid(f"{variant} does not support PDM") | ||||
|         return config | ||||
|     if config[CONF_ADC_TYPE] == "internal": | ||||
|         if variant not in INTERNAL_ADC_VARIANTS: | ||||
| @@ -122,9 +121,8 @@ CONFIG_SCHEMA = cv.All( | ||||
|  | ||||
|  | ||||
| def _final_validate(config): | ||||
|     if not use_legacy(): | ||||
|         if config[CONF_ADC_TYPE] == "internal": | ||||
|             raise cv.Invalid("Internal ADC is only compatible with legacy i2s driver.") | ||||
|     if not use_legacy() and config[CONF_ADC_TYPE] == "internal": | ||||
|         raise cv.Invalid("Internal ADC is only compatible with legacy i2s driver.") | ||||
|  | ||||
|  | ||||
| FINAL_VALIDATE_SCHEMA = _final_validate | ||||
|   | ||||
		Reference in New Issue
	
	Block a user