Skip to content

Commit

Permalink
siegfried - fix ruff issues
Browse files Browse the repository at this point in the history
  • Loading branch information
MatteoCampinoti94 committed Oct 17, 2023
1 parent 290cb4a commit 3b38d07
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions acacore/siegfried/siegfried.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
from os import PathLike
from pathlib import Path
from re import compile as re_compile
from subprocess import CompletedProcess, run
from subprocess import CompletedProcess
from subprocess import run
from typing import Literal
from typing import Optional, Union
from typing import Optional
from typing import Union

from pydantic import BaseModel
from pydantic import ConfigDict
Expand All @@ -23,13 +25,13 @@

def _check_process(process: CompletedProcess) -> CompletedProcess:
"""
Check process and raise exception if it failed.
Raises:
IdentificationError: if the process ends with a return code other than 0.
""" # noqa: D205
"""
if process.returncode != 0:
raise IdentificationError(
process.stderr or process.stdout or f"Unknown siegfried error code {process.returncode}"
)
raise IdentificationError(process.stderr or process.stdout or f"Unknown error code {process.returncode}")

return process

Expand Down Expand Up @@ -121,8 +123,9 @@ def filename_mismatch(self) -> bool:

def sort_tuple(self) -> tuple[int, int, int, int, int]:
"""
Get a tuple of integers useful for sorting matches. The fields used for the tuple are: byte match,
extension match, format, version, and mime.
Get a tuple of integers useful for sorting matches.
The fields used for the tuple are: byte match, extension match, format, version, and mime.
Returns:
A tuple of 5 integers.
Expand Down Expand Up @@ -152,6 +155,7 @@ def unknown_id(cls, data: dict | object):
class SiegfriedFile(BaseModel):
"""
The SiegfriedFile class represents a file that has been analyzed by Siegfried.
It contains information about the file's name, size, modification date, matching results, and any
errors encountered during analysis.
Expand Down Expand Up @@ -224,7 +228,7 @@ class Siegfried:
https://github.com/richardlehane/siegfried
"""

def __init__(self, binary: Union[str, PathLike] = "sf", signature: str = "default.sig"):
def __init__(self, binary: Union[str, PathLike] = "sf", signature: str = "default.sig") -> None:
"""
Initializes a new instance of the Siegfried class.
Expand All @@ -237,7 +241,7 @@ def __init__(self, binary: Union[str, PathLike] = "sf", signature: str = "defaul

def run(self, *args: str) -> CompletedProcess:
"""
Run the Siegfried command
Run the Siegfried command.
Args:
*args: The arguments to be given to Siegfried (excluding the binary path/name).
Expand Down

0 comments on commit 3b38d07

Please sign in to comment.