From 7510f1ea5bb0ad0cc3288b67a05305e1773f1bbd Mon Sep 17 00:00:00 2001 From: Peyman Salehi Date: Sun, 18 Aug 2024 15:02:47 +0200 Subject: [PATCH] Fix ruff issues --- .github/workflows/test.yml | 2 +- pipeline/compressors/__init__.py | 2 +- pipeline/packager.py | 6 +++--- tests/tests/test_compressor.py | 2 +- tests/tests/test_forms.py | 8 ++++---- tests/tests/test_views.py | 2 +- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 68609404..132d0ee9 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -91,4 +91,4 @@ jobs: steps: - uses: actions/checkout@v3 - run: pip install --user ruff - - run: ruff --extend-select=C4,C9,I,PLC,PLE,PLR,U --ignore=C414,I001,PLR0913,UP007,UP032 --target-version=py38 . + - run: ruff check . --extend-select=C4,C9,I,PLC,PLE,PLR,U --ignore=C414,I001,PLR0913,UP007,UP032 --target-version=py38 diff --git a/pipeline/compressors/__init__.py b/pipeline/compressors/__init__.py index fe749500..33597f31 100644 --- a/pipeline/compressors/__init__.py +++ b/pipeline/compressors/__init__.py @@ -320,7 +320,7 @@ def construct_asset_path( os.path.dirname(source_path).replace("\\", "/"), ) if self.embeddable(public_path, variant): - return "__EMBED__%s" % public_path + return f"__EMBED__{public_path}" if not posixpath.isabs(asset_path): asset_path = self.relative_path(public_path, output_filename) return asset_path diff --git a/pipeline/packager.py b/pipeline/packager.py index 20f34197..2dbccb33 100644 --- a/pipeline/packager.py +++ b/pipeline/packager.py @@ -127,10 +127,10 @@ def compile(self, paths, compiler_options={}, force=False): if source_storage is not None: with source_storage.open(path) as source_file: if self.verbose: - print("Saving: %s" % path) + print(f"Saving: {path}") self.storage.save(path, source_file) else: - raise OSError("File does not exist: %s" % path) + raise OSError(f"File does not exist: {path}") return paths def pack(self, package, compress, signal, **kwargs): @@ -168,7 +168,7 @@ def find_source_storage(self, path): for short_path, storage in finder.list(""): if short_path == path: if self.verbose: - print("Found storage: %s" % str(self.storage)) + print(f"Found storage: {str(self.storage)}") return storage return None diff --git a/tests/tests/test_compressor.py b/tests/tests/test_compressor.py index 0a7c7ccd..62d63981 100644 --- a/tests/tests/test_compressor.py +++ b/tests/tests/test_compressor.py @@ -518,7 +518,7 @@ def tearDown(self): def _test_compressor(self, compressor_cls, compress_type, expected_file): override_settings = { - ("%s_COMPRESSOR" % compress_type.upper()): compressor_cls, + (f"{compress_type.upper()}_COMPRESSOR"): compressor_cls, } with pipeline_settings(**override_settings): if compress_type == "js": diff --git a/tests/tests/test_forms.py b/tests/tests/test_forms.py index 2343347f..c2692220 100644 --- a/tests/tests/test_forms.py +++ b/tests/tests/test_forms.py @@ -71,8 +71,8 @@ class MyMedia(PipelineFormMedia): ) self.assertEqual(MyMedia.css, media._css) expected_regex = [ - r'' % path + r''.format(path) for path in ( "/static/extra1.css", "/static/extra2.css", @@ -116,8 +116,8 @@ class MyMedia(PipelineFormMedia): self.assertEqual(MyMedia.css, media._css) expected_regex = [ - '' % path + ''.format(path) for path in ( "/static/extra1.css", "/static/extra2.css", diff --git a/tests/tests/test_views.py b/tests/tests/test_views.py index b05db53c..bba21d1c 100644 --- a/tests/tests/test_views.py +++ b/tests/tests/test_views.py @@ -17,7 +17,7 @@ def setUp(self): self.filename = "pipeline/js/first.js" self.storage = staticfiles_storage - self.request = RequestFactory().get("/static/%s" % self.filename) + self.request = RequestFactory().get(f"/static/{self.filename}") default_collector.clear()