Skip to content
Closed
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
6 changes: 4 additions & 2 deletions scanpipe/pipes/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@
import sys
import time
import uuid
from collections.abc import Callable
from contextlib import suppress
from datetime import datetime
from typing import Any
from itertools import islice
from pathlib import Path

Expand Down Expand Up @@ -548,7 +550,7 @@ def get_resource_diff_ratio(resource_a, resource_b):
)


def poll_until_success(check, sleep=10, **kwargs):
def poll_until_success(check: Callable[..., Any], sleep: int = 10, **kwargs: Any) -> bool:
"""
Given a function `check`, which returns the status of a run, return True
when the run instance has completed successfully.
Expand Down Expand Up @@ -577,7 +579,7 @@ def poll_until_success(check, sleep=10, **kwargs):
time.sleep(sleep)


def run_command_safely(command_args):
def run_command_safely(command_args: list[str]) -> str:
"""
Execute the external commands following security best practices.

Expand Down
1 change: 1 addition & 0 deletions scanpipe/pipes/vulnerablecode.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ def request_post(
data,
timeout=None,
):
"""Wrap the HTTP POST request calls on the API."""
try:
response = session.post(url, json=data, timeout=timeout)
response.raise_for_status()
Expand Down
11 changes: 6 additions & 5 deletions scanpipe/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import operator
from collections import Counter
from contextlib import suppress
from typing import Any

from django.apps import apps
from django.conf import settings
Expand Down Expand Up @@ -192,7 +193,7 @@
]


def purldb_is_configured(*args):
def purldb_is_configured(*args: Any) -> bool:
return purldb.is_configured()


Expand All @@ -203,21 +204,21 @@ def get_queryset(self):
return super().get_queryset().prefetch_related(*self.prefetch_related)


def render_as_yaml(value):
def render_as_yaml(value: Any) -> str | None:
if value:
return saneyaml.dump(value, indent=2)


def render_size(size_in_bytes):
def render_size(size_in_bytes: int | None) -> str | None:
if size_in_bytes:
return f"{size_in_bytes} ({filesizeformat(size_in_bytes)})"


def fields_have_no_values(fields_data):
def fields_have_no_values(fields_data: dict[str, Any]) -> bool:
return not any([field_data.get("value") for field_data in fields_data.values()])


def do_not_disable(*args, **kwargs):
def do_not_disable(*args: Any, **kwargs: Any) -> bool:
return False


Expand Down
Loading