Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ruff: Add and fix PTH112 #11195

Merged
merged 1 commit into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dojo/tools/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def requires_tool_type(scan_type):
package_dir = str(Path(__file__).resolve().parent)
for module_name in os.listdir(package_dir):
# check if it's dir
if os.path.isdir(os.path.join(package_dir, module_name)):
if Path(os.path.join(package_dir, module_name)).is_dir():
try:
# check if it's a Python module
if find_spec(f"dojo.tools.{module_name}.parser"):
Expand Down
2 changes: 1 addition & 1 deletion dojo/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1383,7 +1383,7 @@ def get_page_items_and_count(request, items, page_size, prefix="", do_count=True
def handle_uploaded_threat(f, eng):
_name, extension = os.path.splitext(f.name)
# Check if threat folder exist.
if not os.path.isdir(settings.MEDIA_ROOT + "/threat/"):
if not Path(settings.MEDIA_ROOT + "/threat/").is_dir():
# Create the folder
Path(settings.MEDIA_ROOT + "/threat/").mkdir()
with open(settings.MEDIA_ROOT + f"/threat/{eng.id}{extension}",
Expand Down
2 changes: 1 addition & 1 deletion ruff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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", "PTH112", "PTH114", "PTH115", "PTH116", "PTH117", "PTH119", "PTH121", "PTH124",
"TD001", "TD004", "TD005",
"PD",
"PGH",
Expand Down
2 changes: 1 addition & 1 deletion tests/Import_scanner_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class ScannerTest(BaseTestCase):
def setUp(self):
super().setUp(self)
self.repo_path = dir_path + "/scans"
if os.path.isdir(self.repo_path):
if Path(self.repo_path).is_dir():
shutil.rmtree(self.repo_path)
Path(self.repo_path).mkdir()
git.Repo.clone_from("https://github.com/DefectDojo/sample-scan-files", self.repo_path)
Expand Down
3 changes: 2 additions & 1 deletion unittests/test_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from importlib import import_module
from importlib.util import find_spec
from inspect import isclass
from pathlib import Path

from dojo.models import Test, Test_Type
from dojo.tools.factory import get_parser
Expand Down Expand Up @@ -72,7 +73,7 @@ def test_parser_name_matches_module(self):
for module_name in module_names:
if module_name in excluded_parsers:
continue
if os.path.isdir(os.path.join(package_dir, module_name)):
if Path(os.path.join(package_dir, module_name)).is_dir():
found = False
if find_spec(f"dojo.tools.{module_name}.parser"):
module = import_module(f"dojo.tools.{module_name}.parser")
Expand Down
2 changes: 1 addition & 1 deletion unittests/test_parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def test_file_existence(self):
with self.subTest(parser=parser_dir.name, category="testfiles"):
scan_dir = os.path.join(basedir, "unittests", "scans", parser_dir.name)
self.assertTrue(
os.path.isdir(scan_dir),
Path(scan_dir).is_dir(),
f"Test files for unittest of parser '{scan_dir}' are missing or using different name",
)

Expand Down
Loading