From 6cfb8d161cc6d1e2042ef2509f960b61f218ab1d Mon Sep 17 00:00:00 2001 From: Orange Kao Date: Wed, 3 Nov 2021 06:08:08 +0000 Subject: [PATCH] Fix CI - pylint Github pylint check will return make: [Makefile:50: pylint] Error 127 (ignored) and pylint check has been skipped because in Makefile $(PYLINT) is an empty string Fix the Makefile and everything pylint compaints Disable unspecified-encoding (when open()) because Windows is not our target platform --- .pylintrc | 3 ++- Makefile | 2 +- rpm_s3_mirror/mirror.py | 2 +- rpm_s3_mirror/repository.py | 2 +- rpm_s3_mirror/statsd.py | 2 +- 5 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.pylintrc b/.pylintrc index 8e74d1d..a62851e 100644 --- a/.pylintrc +++ b/.pylintrc @@ -36,7 +36,8 @@ disable= line-too-long, no-else-continue, no-else-break, - import-outside-toplevel + import-outside-toplevel, + unspecified-encoding [FORMAT] max-line-length=125 diff --git a/Makefile b/Makefile index 8bdf85c..4235683 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ all: PYTHON ?= python3 PYTHON_SOURCE_DIRS = rpm_s3_mirror/ tests/ PYTEST_ARG ?= -v -PYLINT=$(shell which pylint 2> /dev/null | which pylint-3) +PYLINT=$(shell which pylint 2> /dev/null || which pylint-3) clean: $(RM) -r *.egg-info/ build/ dist/ rpm/ diff --git a/rpm_s3_mirror/mirror.py b/rpm_s3_mirror/mirror.py index 530fd52..7a62d33 100644 --- a/rpm_s3_mirror/mirror.py +++ b/rpm_s3_mirror/mirror.py @@ -68,7 +68,7 @@ def _sync_repository(self, upstream_repository): upstream_metadata = upstream_repository.parse_metadata() mirror_repository = RPMRepository(base_url=self._build_s3_url(upstream_repository.base_url)) - bootstrap = False if mirror_repository.exists() else True + bootstrap = not mirror_repository.exists() if bootstrap: self.log.info("Bootstrapping repository: %s", upstream_repository.base_url) new_packages = upstream_metadata.package_list diff --git a/rpm_s3_mirror/repository.py b/rpm_s3_mirror/repository.py index 1dbf23f..300c064 100644 --- a/rpm_s3_mirror/repository.py +++ b/rpm_s3_mirror/repository.py @@ -284,7 +284,7 @@ def parse_repomd(self, xml: Element) -> Dict[str, RepodataSection]: return sections def _req(self, method, path, *, json=None, params=None, acceptible_status_code=None, **kwargs) -> Response: - acceptible_status_code = acceptible_status_code if acceptible_status_code else {200} + acceptible_status_code = acceptible_status_code or {200} url = f"{self.base_url}{path}" response = method(url, json=json, params=params, **kwargs) if response.status_code not in acceptible_status_code: diff --git a/rpm_s3_mirror/statsd.py b/rpm_s3_mirror/statsd.py index 1922563..d5eb1a4 100644 --- a/rpm_s3_mirror/statsd.py +++ b/rpm_s3_mirror/statsd.py @@ -66,6 +66,6 @@ def _send(self, metric, metric_type, value, tags): parts.append(pattern.format(separator, tag, val).encode("utf-8")) else: for tag, val in send_tags.items(): - parts.insert(1, ",{}={}".format(tag, val).encode("utf-8")) + parts.insert(1, f",{tag}={val}".encode("utf-8")) self._socket.sendto(b"".join(parts), self._dest_addr)