Bump pylint from 2.10.2 to 2.11.1 (#3128)

* Bump pylint from 2.10.2 to 2.11.1

Bumps [pylint](https://github.com/PyCQA/pylint) from 2.10.2 to 2.11.1.
- [Release notes](https://github.com/PyCQA/pylint/releases)
- [Changelog](https://github.com/PyCQA/pylint/blob/main/ChangeLog)
- [Commits](https://github.com/PyCQA/pylint/compare/v2.10.2...v2.11.1)

---
updated-dependencies:
- dependency-name: pylint
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* Fix linter issues

* fix tests lint

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Pascal Vizeli <pvizeli@syshack.ch>
This commit is contained in:
dependabot[bot] 2021-09-22 14:33:32 +02:00 committed by GitHub
parent 96f6c07912
commit a85e816cd7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 18 additions and 24 deletions

View File

@ -5,7 +5,7 @@ flake8-docstrings==1.6.0
flake8==3.9.2 flake8==3.9.2
pre-commit==2.15.0 pre-commit==2.15.0
pydocstyle==6.1.1 pydocstyle==6.1.1
pylint==2.10.2 pylint==2.11.1
pytest-aiohttp==0.3.0 pytest-aiohttp==0.3.0
pytest-asyncio==0.12.0 # NB!: Versions over 0.12.0 breaks pytest-aiohttp (https://github.com/aio-libs/pytest-aiohttp/issues/16) pytest-asyncio==0.12.0 # NB!: Versions over 0.12.0 breaks pytest-aiohttp (https://github.com/aio-libs/pytest-aiohttp/issues/16)
pytest-cov==2.12.1 pytest-cov==2.12.1

View File

@ -530,8 +530,7 @@ class Addon(AddonModel):
# Write pulse config # Write pulse config
try: try:
with self.path_pulse.open("w") as config_file: self.path_pulse.write_text(pulse_config, encoding="utf-8")
config_file.write(pulse_config)
except OSError as err: except OSError as err:
_LOGGER.error( _LOGGER.error(
"Add-on %s can't write pulse/client.config: %s", self.slug, err "Add-on %s can't write pulse/client.config: %s", self.slug, err

View File

@ -184,8 +184,7 @@ class AddonModel(CoreSysAttributes, ABC):
return None return None
# Return data # Return data
with readme.open("r") as readme_file: return readme.read_text(encoding="utf-8")
return readme_file.read()
@property @property
def repository(self) -> str: def repository(self) -> str:

View File

@ -94,7 +94,7 @@ async def initialize_coresys() -> CoreSys:
# Set Machine/Host ID # Set Machine/Host ID
if MACHINE_ID.exists(): if MACHINE_ID.exists():
coresys.machine_id = MACHINE_ID.read_text().strip() coresys.machine_id = MACHINE_ID.read_text(encoding="utf-8").strip()
# Check if ENV is in development mode # Check if ENV is in development mode
if coresys.dev: if coresys.dev:

View File

@ -55,7 +55,7 @@ class Core(CoreSysAttributes):
if self._state == new_state: if self._state == new_state:
return return
try: try:
RUN_SUPERVISOR_STATE.write_text(new_state.value) RUN_SUPERVISOR_STATE.write_text(new_state.value, encoding="utf-8")
except OSError as err: except OSError as err:
_LOGGER.warning( _LOGGER.warning(
"Can't update the Supervisor state to %s: %s", new_state, err "Can't update the Supervisor state to %s: %s", new_state, err

View File

@ -32,9 +32,7 @@ def interface_update_payload(
def ipv6_to_byte(ip_address: IPv6Address) -> str: def ipv6_to_byte(ip_address: IPv6Address) -> str:
"""Convert an ipv6 to an byte array.""" """Convert an ipv6 to an byte array."""
return ( return f'[byte {", ".join(f"0x{val:02x}" for val in ip_address.packed)}]'
f'[byte {", ".join("0x{:02x}".format(val) for val in ip_address.packed)}]'
)
# Init template # Init template
env.filters["ipv4_to_int"] = ipv4_to_int env.filters["ipv4_to_int"] = ipv4_to_int

View File

@ -65,7 +65,7 @@ class HwDisk(CoreSysAttributes):
return round(free / (1024.0 ** 3), 1) return round(free / (1024.0 ** 3), 1)
def _get_mountinfo(self, path: str) -> str: def _get_mountinfo(self, path: str) -> str:
mountinfo = _MOUNTINFO.read_text() mountinfo = _MOUNTINFO.read_text(encoding="utf-8")
for line in mountinfo.splitlines(): for line in mountinfo.splitlines():
mountinfoarr = line.split() mountinfoarr = line.split()
if mountinfoarr[4] == path: if mountinfoarr[4] == path:
@ -92,7 +92,7 @@ class HwDisk(CoreSysAttributes):
return None return None
# JEDEC health status DEVICE_LIFE_TIME_EST_TYP_A/B # JEDEC health status DEVICE_LIFE_TIME_EST_TYP_A/B
emmc_life_time = life_time_path.read_text().split() emmc_life_time = life_time_path.read_text(encoding="utf-8").split()
if len(emmc_life_time) < 2: if len(emmc_life_time) < 2:
return None return None

View File

@ -45,8 +45,7 @@ class HwHelper(CoreSysAttributes):
def last_boot(self) -> Optional[str]: def last_boot(self) -> Optional[str]:
"""Return last boot time.""" """Return last boot time."""
try: try:
with _PROC_STAT.open("r") as stat_file: stats: str = _PROC_STAT.read_text(encoding="utf-8")
stats: str = stat_file.read()
except OSError as err: except OSError as err:
_LOGGER.error("Can't read stat data: %s", err) _LOGGER.error("Can't read stat data: %s", err)
return None return None

View File

@ -114,8 +114,8 @@ class HomeAssistant(FileConfiguration, CoreSysAttributes):
@property @property
def api_url(self) -> str: def api_url(self) -> str:
"""Return API url to Home Assistant.""" """Return API url to Home Assistant."""
return "{}://{}:{}".format( return (
"https" if self.api_ssl else "http", self.ip_address, self.api_port f"{'https' if self.api_ssl else 'http'}://{self.ip_address}:{self.api_port}"
) )
@property @property
@ -257,8 +257,7 @@ class HomeAssistant(FileConfiguration, CoreSysAttributes):
# Write pulse config # Write pulse config
try: try:
with self.path_pulse.open("w") as config_file: self.path_pulse.write_text(pulse_config, encoding="utf-8")
config_file.write(pulse_config)
except OSError as err: except OSError as err:
_LOGGER.error("Home Assistant can't write pulse/client.config: %s", err) _LOGGER.error("Home Assistant can't write pulse/client.config: %s", err)
else: else:

View File

@ -312,7 +312,7 @@ class PluginDns(PluginBase):
data = self.hosts_template.render(entries=self._hosts) data = self.hosts_template.render(entries=self._hosts)
try: try:
self.hosts.write_text(data) self.hosts.write_text(data, encoding="utf-8")
except OSError as err: except OSError as err:
_LOGGER.error("Can't update hosts: %s", err) _LOGGER.error("Can't update hosts: %s", err)
raise CoreDNSError() from err raise CoreDNSError() from err

View File

@ -35,6 +35,6 @@ class EvaluateAppArmor(EvaluateBase):
async def evaluate(self) -> None: async def evaluate(self) -> None:
"""Run evaluation.""" """Run evaluation."""
try: try:
return _APPARMOR_KERNEL.read_text().strip().upper() != "Y" return _APPARMOR_KERNEL.read_text(encoding="utf-8").strip().upper() != "Y"
except OSError: except OSError:
return True return True

View File

@ -34,6 +34,6 @@ class EvaluateLxc(EvaluateBase):
async def evaluate(self): async def evaluate(self):
"""Run evaluation.""" """Run evaluation."""
with suppress(OSError): with suppress(OSError):
if "container=lxc" in Path("/proc/1/environ").read_text(): if "container=lxc" in Path("/proc/1/environ").read_text(encoding="utf-8"):
return True return True
return Path("/dev/lxd/sock").exists() return Path("/dev/lxd/sock").exists()

View File

@ -143,7 +143,7 @@ class Supervisor(CoreSysAttributes):
with TemporaryDirectory(dir=self.sys_config.path_tmp) as tmp_dir: with TemporaryDirectory(dir=self.sys_config.path_tmp) as tmp_dir:
profile_file = Path(tmp_dir, "apparmor.txt") profile_file = Path(tmp_dir, "apparmor.txt")
try: try:
profile_file.write_text(data) profile_file.write_text(data, encoding="utf-8")
except OSError as err: except OSError as err:
raise SupervisorAppArmorError( raise SupervisorAppArmorError(
f"Can't write temporary profile: {err!s}", _LOGGER.error f"Can't write temporary profile: {err!s}", _LOGGER.error

View File

@ -6,13 +6,13 @@ from pathlib import Path
def load_json_fixture(filename: str) -> dict: def load_json_fixture(filename: str) -> dict:
"""Load a json fixture.""" """Load a json fixture."""
path = Path(Path(__file__).parent.joinpath("fixtures"), filename) path = Path(Path(__file__).parent.joinpath("fixtures"), filename)
return json.loads(path.read_text()) return json.loads(path.read_text(encoding="utf-8"))
def load_fixture(filename: str) -> str: def load_fixture(filename: str) -> str:
"""Load a fixture.""" """Load a fixture."""
path = Path(Path(__file__).parent.joinpath("fixtures"), filename) path = Path(Path(__file__).parent.joinpath("fixtures"), filename)
return path.read_text() return path.read_text(encoding="utf-8")
def exists_fixture(filename: str) -> bool: def exists_fixture(filename: str) -> bool: