Skip to content

Commit

Permalink
feat: fix formatting with ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
0hsn committed Dec 27, 2024
1 parent c517451 commit 71f4ae8
Show file tree
Hide file tree
Showing 11 changed files with 38 additions and 34 deletions.
1 change: 1 addition & 0 deletions chk/__main__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
chk cli
"""

from chk.console.main import chk

if __name__ == "__main__":
Expand Down
6 changes: 2 additions & 4 deletions chk/infrastructure/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,8 @@ def try_dict(to_dict: Any, say_exception: bool = False) -> dict | Any:


def formatter(
message: object,
cb: Callable = str,
dump: bool = True,
is_err: bool = False) -> str:
message: object, cb: Callable = str, dump: bool = True, is_err: bool = False
) -> str:
"""Format message with given callback
Args:
Expand Down
12 changes: 4 additions & 8 deletions chk/infrastructure/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,9 @@
class LoggingManager:
"""LoggingManager"""

cache_dir = '.chkware_cache/'
loggin_dir = 'logs/'
loggin_ext = '.log'

cache_dir = ".chkware_cache/"
loggin_dir = "logs/"
loggin_ext = ".log"

@classmethod
def create_cache_dir(cls) -> Path:
Expand All @@ -43,7 +42,6 @@ def create_cache_dir(cls) -> Path:

return cache_path


@classmethod
def create_log_dir(cls, parent: Path) -> Path:
"""create_cache_dir"""
Expand All @@ -57,12 +55,11 @@ def create_log_dir(cls, parent: Path) -> Path:

return log_dir


@classmethod
def create_new_log_file(cls) -> Path:
"""create new log file"""

cache_dir =cls.create_cache_dir()
cache_dir = cls.create_cache_dir()
log_dir = cls.create_log_dir(cache_dir)

log_file = log_dir / create_session_id()
Expand All @@ -84,7 +81,6 @@ def remove_loguru(cls) -> None:
logger.remove()



def create_session_id() -> str:
"""create_session_id"""

Expand Down
25 changes: 13 additions & 12 deletions chk/infrastructure/symbol_table.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Symbol and variable management
"""

from __future__ import annotations

import copy
Expand Down Expand Up @@ -108,10 +109,10 @@ class VariableTableManager:

@classmethod
def handle(
cls,
variable_doc: Variables,
document: VersionedDocument | VersionedDocumentV2,
exec_ctx: ExecuteContext,
cls,
variable_doc: Variables,
document: VersionedDocument | VersionedDocumentV2,
exec_ctx: ExecuteContext,
) -> None:
"""Handles variable handling
Expand Down Expand Up @@ -151,10 +152,10 @@ def handle_absolute(cls, variable_doc: Variables, document: dict) -> None:

@classmethod
def handle_composite(
cls,
variable_doc: Variables,
document: dict,
replace_callback: Callable = replace_value,
cls,
variable_doc: Variables,
document: dict,
replace_callback: Callable = replace_value,
) -> None:
"""Handles absolute variables and values from document
Expand All @@ -178,7 +179,7 @@ def handle_composite(

@classmethod
def handle_execute_context(
cls, variable_doc: Variables, exec_ctx: ExecuteContext
cls, variable_doc: Variables, exec_ctx: ExecuteContext
) -> None:
"""Handle variables passed from external context
Expand Down Expand Up @@ -220,9 +221,9 @@ def get_expose_doc(document: dict) -> list:

@staticmethod
def replace_values(
expose_doc: list,
values: dict,
replace_callback: Callable = replace_value,
expose_doc: list,
values: dict,
replace_callback: Callable = replace_value,
) -> list:
"""Replace values on expose document
Expand Down
5 changes: 4 additions & 1 deletion chk/infrastructure/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,10 @@ def display(
else:
formatter(wfp.dump_json(), dump=exec_ctx.options["dump"])

def die_with_error(err: Exception, Presenter: type[PresentationBuilder], is_fmt: bool) -> None:

def die_with_error(
err: Exception, Presenter: type[PresentationBuilder], is_fmt: bool
) -> None:
"""die_with_error"""

prs = Presenter(data=None)
Expand Down
1 change: 1 addition & 0 deletions chk/modules/fetch/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Fetch module
"""

import sys
from collections import abc

Expand Down
9 changes: 6 additions & 3 deletions chk/modules/fetch/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
EXPOSE_SCHEMA as EXP_SCHEMA,
VARIABLE_SCHEMA as VAR_SCHEMA,
Variables,
replace_value
replace_value,
)
from chk.infrastructure.version import (
DocumentVersionMaker,
Expand All @@ -27,9 +27,12 @@
from chk.modules.fetch.entities import (
ApiResponseModel,
BearerAuthentication,
CTYPE_XML, HttpDocument,
CTYPE_XML,
HttpDocument,
HttpMethod,
RequestConfigNode, SCHEMA, VERSION_SCOPE,
RequestConfigNode,
SCHEMA,
VERSION_SCOPE,
)


Expand Down
1 change: 0 additions & 1 deletion chk/modules/validate/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,6 @@ def call(file_ctx: FileContext, exec_ctx: ExecuteContext) -> ExecResponse:
validate_doc = ValidationDocument()

try:

validate_doc = ValidationDocument.from_file_context(file_ctx)
debug(validate_doc.model_dump_json())

Expand Down
1 change: 1 addition & 0 deletions chk/modules/validate/assertion_function.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Assertion Functions mod
"""

import datetime
import types
from typing import TypeAlias, Union
Expand Down
10 changes: 6 additions & 4 deletions chk/modules/validate/entities.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,13 @@ def __iter__(self) -> Generator:
yield "msg_pass", self.msg_pass
yield "msg_fail", self.msg_fail
yield "cast_actual_to", self.cast_actual_to
yield "actual_given", (
"" if self.actual_given == NotImplemented else self.actual_given
yield (
"actual_given",
("" if self.actual_given == NotImplemented else self.actual_given),
)
yield "actual_b4_cast", (
"" if self.actual_b4_cast == NotImplemented else self.actual_b4_cast
yield (
"actual_b4_cast",
("" if self.actual_b4_cast == NotImplemented else self.actual_b4_cast),
)
yield "extra_fields", self.extra_fields

Expand Down
1 change: 0 additions & 1 deletion chk/modules/workflow/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ def _prepare_dump_data(self) -> dict:
"exception": repr(item.exception),
}
if item.task.uses == "fetch":

response_task_dump["fetch_request_method"] = (
item.others["request_method"]
if "request_method" in item.others
Expand Down

0 comments on commit 71f4ae8

Please sign in to comment.