Fix some lint errors in pylint 2.10.2 (#2226)

This commit is contained in:
Jesse Hills 2021-08-31 14:00:58 +12:00 committed by GitHub
parent 140ef791aa
commit 54337befc2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 18 additions and 14 deletions

View File

@ -91,7 +91,7 @@ async def mcp23xxx_pin_to_code(config):
# BEGIN Removed pin schemas below to show error in configuration
# TODO remove in 1.19.0
# TODO remove in 2022.5.0
for id in ["mcp23008", "mcp23s08", "mcp23017", "mcp23s17"]:
PIN_SCHEMA = cv.Schema(
@ -110,6 +110,7 @@ for id in ["mcp23008", "mcp23s08", "mcp23017", "mcp23s17"]:
}
)
# pylint: disable=cell-var-from-loop
@pins.PIN_SCHEMA_REGISTRY.register(id, (PIN_SCHEMA, PIN_SCHEMA))
def pin_to_code(config):
pass

View File

@ -62,10 +62,10 @@ async def to_code(config):
if CONF_CSS_INCLUDE in config:
cg.add_define("WEBSERVER_CSS_INCLUDE")
path = CORE.relative_config_path(config[CONF_CSS_INCLUDE])
with open(path, "r") as myfile:
with open(file=path, mode="r", encoding="utf-8") as myfile:
cg.add(var.set_css_include(myfile.read()))
if CONF_JS_INCLUDE in config:
cg.add_define("WEBSERVER_JS_INCLUDE")
path = CORE.relative_config_path(config[CONF_JS_INCLUDE])
with open(path, "r") as myfile:
with open(file=path, mode="r", encoding="utf-8") as myfile:
cg.add(var.set_js_include(myfile.read()))

View File

@ -836,10 +836,11 @@ pressure = float_with_unit("pressure", "(bar|Bar)", optional_unit=True)
def temperature(value):
err = None
try:
return _temperature_c(value)
except Invalid as orig_err: # noqa
pass
except Invalid as orig_err:
err = orig_err
try:
kelvin = _temperature_k(value)
@ -853,7 +854,7 @@ def temperature(value):
except Invalid:
pass
raise orig_err # noqa
raise err
_color_temperature_mireds = float_with_unit("Color Temperature", r"(mireds|Mireds)")

View File

@ -600,7 +600,7 @@ class EditRequestHandler(BaseHandler):
content = ""
if os.path.isfile(filename):
# pylint: disable=no-value-for-parameter
with open(filename, "r") as f:
with open(file=filename, mode="r", encoding="utf-8") as f:
content = f.read()
self.write(content)
@ -608,7 +608,9 @@ class EditRequestHandler(BaseHandler):
@bind_config
def post(self, configuration=None):
# pylint: disable=no-value-for-parameter
with open(settings.rel_path(configuration), "wb") as f:
with open(
file=settings.rel_path(configuration), mode="wb", encoding="utf-8"
) as f:
f.write(self.request.body)
self.set_status(200)

View File

@ -276,11 +276,11 @@ def file_compare(path1: os.PathLike, path2: os.PathLike) -> bool:
# A dict of types that need to be converted to heaptypes before a class can be added
# to the object
_TYPE_OVERLOADS = {
int: type("EInt", (int,), dict()),
float: type("EFloat", (float,), dict()),
str: type("EStr", (str,), dict()),
dict: type("EDict", (str,), dict()),
list: type("EList", (list,), dict()),
int: type("EInt", (int,), {}),
float: type("EFloat", (float,), {}),
str: type("EStr", (str,), {}),
dict: type("EDict", (str,), {}),
list: type("EList", (list,), {}),
}
# cache created classes here

View File

@ -481,5 +481,5 @@ GITIGNORE_CONTENT = """# Gitignore settings for ESPHome
def write_gitignore():
path = CORE.relative_config_path(".gitignore")
if not os.path.isfile(path):
with open(path, "w") as f:
with open(file=path, mode="w", encoding="utf-8") as f:
f.write(GITIGNORE_CONTENT)