From 8deaddf993431b585e4a38b2b038d11408f10899 Mon Sep 17 00:00:00 2001 From: Manuel Sommer Date: Tue, 5 Nov 2024 12:20:21 +0100 Subject: [PATCH] Ruff: Add and fix PTH113 --- dojo/settings/.settings.dist.py.sha256sum | 2 +- dojo/settings/settings.dist.py | 3 ++- ruff.toml | 2 +- unittests/test_parsers.py | 8 ++++---- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/dojo/settings/.settings.dist.py.sha256sum b/dojo/settings/.settings.dist.py.sha256sum index 259f13a4c69..8378b802d5a 100644 --- a/dojo/settings/.settings.dist.py.sha256sum +++ b/dojo/settings/.settings.dist.py.sha256sum @@ -1 +1 @@ -6b9365d002880ae64ab54da905ede076db5a8661960f8f1e2793b7f4d25ff7e8 +9860316f077ad0fea78686f7a30cc9088eadf303f79348d1185f6bce77765703 diff --git a/dojo/settings/settings.dist.py b/dojo/settings/settings.dist.py index 9920533272f..3989a4884cc 100644 --- a/dojo/settings/settings.dist.py +++ b/dojo/settings/settings.dist.py @@ -17,6 +17,7 @@ import warnings from datetime import timedelta from email.utils import getaddresses +from pathlib import Path import environ from celery.schedules import crontab @@ -332,7 +333,7 @@ def generate_url(scheme, double_slashes, user, password, host, port, path, param # Read .env file as default or from the command line, DD_ENV_PATH -if os.path.isfile(root("dojo/settings/.env.prod")) or "DD_ENV_PATH" in os.environ: +if Path.is_file(root("dojo/settings/.env.prod")) or "DD_ENV_PATH" in os.environ: env.read_env(root("dojo/settings/" + env.str("DD_ENV_PATH", ".env.prod"))) # ------------------------------------------------------------------------------ diff --git a/ruff.toml b/ruff.toml index 3a360f49891..c05a2649a0f 100644 --- a/ruff.toml +++ b/ruff.toml @@ -65,7 +65,7 @@ select = [ "TCH", "INT", "ARG003", "ARG004", "ARG005", - "PTH2", "PTH101", "PTH102", "PTH103", "PTH104", "PTH105", "PTH106", "PTH107", "PTH108", "PTH109", "PTH110", "PTH111", "PTH114", "PTH115", "PTH116", "PTH117", "PTH119", "PTH121", "PTH124", + "PTH2", "PTH101", "PTH102", "PTH103", "PTH104", "PTH105", "PTH106", "PTH107", "PTH108", "PTH109", "PTH110", "PTH111", "PTH113", "PTH114", "PTH115", "PTH116", "PTH117", "PTH119", "PTH121", "PTH124", "TD001", "TD004", "TD005", "PD", "PGH", diff --git a/unittests/test_parsers.py b/unittests/test_parsers.py index 9e2ac077f14..aaa484b0ea4 100644 --- a/unittests/test_parsers.py +++ b/unittests/test_parsers.py @@ -30,7 +30,7 @@ def test_file_existence(self): with self.subTest(parser=parser_dir.name, category="docs"): doc_file = os.path.join(basedir, "docs", "content", "en", "integrations", "parsers", category, f"{doc_name}.md") self.assertTrue( - os.path.isfile(doc_file), + Path.is_file(doc_file), f"Documentation file '{doc_file}' is missing or using different name", ) @@ -55,7 +55,7 @@ def test_file_existence(self): with self.subTest(parser=parser_dir.name, category="parser"): parser_test_file = os.path.join(basedir, "unittests", "tools", f"test_{parser_dir.name}_parser.py") self.assertTrue( - os.path.isfile(parser_test_file), + Path.is_file(parser_test_file), f"Unittest of parser '{parser_test_file}' is missing or using different name", ) @@ -78,7 +78,7 @@ def test_file_existence(self): with self.subTest(parser=parser_dir.name, category="importer"): importer_test_file = os.path.join(basedir, "unittests", "tools", f"test_{parser_dir.name}_importer.py") self.assertTrue( - os.path.isfile(importer_test_file), + Path.is_file(importer_test_file), f"Unittest of importer '{importer_test_file}' is missing or using different name", ) for file in os.scandir(os.path.join(basedir, "dojo", "tools", parser_dir.name)): @@ -110,6 +110,6 @@ def test_parser_existence(self): with self.subTest(parser=docs.name.split(".md")[0], category="parser"): parser = os.path.join(basedir, "dojo", "tools", f"{docs.name.split('.md')[0]}", "parser.py") self.assertTrue( - os.path.isfile(parser), + path.is_file(parser), f"Parser '{parser}' is missing or using different name", )