Handle more file closing using context manager (#11942)
This commit is contained in:
1 parent
4cb1f93019
commit
0376cc0917
4 files changed
+12
-11
No files matched your search
@@ -66,8 +66,8 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
device_file, 'temperature'))
|
||||
else:
|
||||
for family_file_path in glob(os.path.join(base_dir, '*', 'family')):
|
||||
family_file = open(family_file_path, "r")
|
||||
family = family_file.read()
|
||||
with open(family_file_path, "r") as family_file:
|
||||
family = family_file.read()
|
||||
if family in DEVICE_SENSORS:
|
||||
for sensor_key, sensor_value in DEVICE_SENSORS[family].items():
|
||||
sensor_id = os.path.split(
|
||||
|
||||
Reference in new issue
Block a user