From 01419822f73e8784ed7047950c437b5416efb861 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 16 Apr 2024 10:59:44 +1200 Subject: [PATCH] Bump pylint from 3.0.3 to 3.1.0 (#6287) Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com> --- esphome/components/font/__init__.py | 3 +-- esphome/components/time/__init__.py | 2 +- esphome/loader.py | 13 ++++++++++--- requirements_test.txt | 2 +- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/esphome/components/font/__init__.py b/esphome/components/font/__init__.py index 76eb05e6ad..b3a5beb199 100644 --- a/esphome/components/font/__init__.py +++ b/esphome/components/font/__init__.py @@ -400,8 +400,7 @@ class BitmapFontWrapper: for glyph in glyphs: mask = self.getmask(glyph, mode="1") _, height = mask.size - if height > max_height: - max_height = height + max_height = max(max_height, height) return (max_height, 0) diff --git a/esphome/components/time/__init__.py b/esphome/components/time/__init__.py index 2bb3a0cd63..c888705ba2 100644 --- a/esphome/components/time/__init__.py +++ b/esphome/components/time/__init__.py @@ -49,7 +49,7 @@ def _load_tzdata(iana_key: str) -> Optional[bytes]: package = "tzdata.zoneinfo." + package_loc.replace("/", ".") try: - return resources.read_binary(package, resource) + return (resources.files(package) / resource).read_bytes() except (FileNotFoundError, ModuleNotFoundError): return None diff --git a/esphome/loader.py b/esphome/loader.py index 40a38d0a14..e0457eb425 100644 --- a/esphome/loader.py +++ b/esphome/loader.py @@ -23,7 +23,9 @@ class FileResource: resource: str def path(self) -> ContextManager[Path]: - return importlib.resources.path(self.package, self.resource) + return importlib.resources.as_file( + importlib.resources.files(self.package) / self.resource + ) class ComponentManifest: @@ -101,10 +103,15 @@ class ComponentManifest: loaded .py file (does not look through subdirectories) """ ret = [] - for resource in importlib.resources.contents(self.package): + + for resource in ( + r.name + for r in importlib.resources.files(self.package).iterdir() + if r.is_file() + ): if Path(resource).suffix not in SOURCE_FILE_EXTENSIONS: continue - if not importlib.resources.is_resource(self.package, resource): + if not importlib.resources.files(self.package).joinpath(resource).is_file(): # Not a resource = this is a directory (yeah this is confusing) continue ret.append(FileResource(self.package, resource)) diff --git a/requirements_test.txt b/requirements_test.txt index f94b2a5c51..16e9ec7422 100644 --- a/requirements_test.txt +++ b/requirements_test.txt @@ -1,4 +1,4 @@ -pylint==3.0.3 +pylint==3.1.0 flake8==7.0.0 # also change in .pre-commit-config.yaml when updating black==24.4.0 # also change in .pre-commit-config.yaml when updating pyupgrade==3.15.1 # also change in .pre-commit-config.yaml when updating