From 4f0a2717f43270434f199dea62f40cec5098ee55 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 1 Jan 2025 20:47:02 -0300 Subject: [PATCH] commit(deps): bump astral-sh/setup-uv from 4 to 5 (#4) * commit(deps): bump astral-sh/setup-uv from 4 to 5 Bumps [astral-sh/setup-uv](https://github.com/astral-sh/setup-uv) from 4 to 5. - [Release notes](https://github.com/astral-sh/setup-uv/releases) - [Commits](https://github.com/astral-sh/setup-uv/compare/v4...v5) --- updated-dependencies: - dependency-name: astral-sh/setup-uv dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .github/workflows/new_release.yml | 2 +- ejemplo.py | 5 +---- khipu_tools/__init__.py | 22 ++++++++-------------- khipu_tools/_api_requestor.py | 11 +++-------- khipu_tools/_banks.py | 4 +--- khipu_tools/_encode.py | 4 +--- khipu_tools/_error.py | 5 +---- khipu_tools/_http_client.py | 16 ++++------------ khipu_tools/_khipu_object.py | 7 ++----- khipu_tools/_list_object.py | 13 +++---------- khipu_tools/_listable_api_resource.py | 4 +--- khipu_tools/_payments.py | 12 +++--------- khipu_tools/_predict.py | 4 +--- khipu_tools/_util.py | 5 +---- 14 files changed, 31 insertions(+), 83 deletions(-) diff --git a/.github/workflows/new_release.yml b/.github/workflows/new_release.yml index f9bc655..91b140d 100644 --- a/.github/workflows/new_release.yml +++ b/.github/workflows/new_release.yml @@ -19,7 +19,7 @@ jobs: - uses: actions/checkout@v4 - name: Set up uv - uses: astral-sh/setup-uv@v4 + uses: astral-sh/setup-uv@v5 with: python-version: ${{ matrix.python-version }} diff --git a/ejemplo.py b/ejemplo.py index f30bd90..fcb83e3 100644 --- a/ejemplo.py +++ b/ejemplo.py @@ -95,10 +95,7 @@ def list_unused_files(tracked_files, project_directory): # Format the output as the required JSON structure output = [] for file_name, functions in function_calls.items(): - modules = [ - {"function": func_name, "count": count} - for func_name, count in functions.items() - ] + modules = [{"function": func_name, "count": count} for func_name, count in functions.items()] output.append({"file": file_name, "modules": modules}) # Print the JSON string diff --git a/khipu_tools/__init__.py b/khipu_tools/__init__.py index dd4d24c..e9cae0e 100644 --- a/khipu_tools/__init__.py +++ b/khipu_tools/__init__.py @@ -1,3 +1,11 @@ +from khipu_tools._predict import Predict as Predict +from khipu_tools._payments import Payments as Payments +from khipu_tools._banks import Banks as Banks +from khipu_tools._http_client import ( + new_default_http_client as new_default_http_client, +) +from khipu_tools._api_resource import APIResource as APIResource +from khipu_tools._khipu_client import KhipuClient as KhipuClient from typing import Optional from typing import Literal @@ -44,17 +52,3 @@ def set_app_info( # Infrastructure types -from khipu_tools._khipu_client import KhipuClient as KhipuClient -from khipu_tools._api_resource import APIResource as APIResource - - -from khipu_tools._http_client import ( - new_default_http_client as new_default_http_client, -) - - -from khipu_tools._banks import Banks as Banks - -from khipu_tools._payments import Payments as Payments - -from khipu_tools._predict import Predict as Predict diff --git a/khipu_tools/_api_requestor.py b/khipu_tools/_api_requestor.py index d58f78a..f207b61 100644 --- a/khipu_tools/_api_requestor.py +++ b/khipu_tools/_api_requestor.py @@ -85,9 +85,7 @@ def _replace_options(self, options: Optional[RequestOptions]) -> "_APIRequestor" ]: if key in options and options[key] is not None: new_options[key] = options[key] - return _APIRequestor( - options=RequestorOptions(**new_options), client=self._client - ) + return _APIRequestor(options=RequestorOptions(**new_options), client=self._client) @property def api_key(self): @@ -147,9 +145,7 @@ def request( return obj - def request_headers( - self, method: HttpVerb, api_mode: ApiMode, options: RequestOptions - ): + def request_headers(self, method: HttpVerb, api_mode: ApiMode, options: RequestOptions): user_agent = f"khipu_tools/{khipu_tools.VERSION}" if khipu_tools.app_info: user_agent += " " + self._format_app_info(khipu_tools.app_info) @@ -317,8 +313,7 @@ def _interpret_response( ) except Exception: raise error.APIError( - f"Invalid response body from API: {rcode} -- " - f"HTTP response was: {rbody})", + f"Invalid response body from API: {rcode} -- " f"HTTP response was: {rbody})", cast(bytes, rbody), rcode, cast(bytes, rbody), diff --git a/khipu_tools/_banks.py b/khipu_tools/_banks.py index d84ca2c..00af436 100644 --- a/khipu_tools/_banks.py +++ b/khipu_tools/_banks.py @@ -46,8 +46,6 @@ def get(cls) -> KhipuObject["Banks"]: cls.class_url(), ) if not isinstance(result, KhipuObject): - raise TypeError( - "Expected KhipuObject object from API, got %s" % (type(result).__name__) - ) + raise TypeError("Expected KhipuObject object from API, got %s" % (type(result).__name__)) return result diff --git a/khipu_tools/_encode.py b/khipu_tools/_encode.py index 895efd3..49eb001 100644 --- a/khipu_tools/_encode.py +++ b/khipu_tools/_encode.py @@ -28,9 +28,7 @@ def _json_encode_date_callback(value): return value -def _api_encode( - data, api_mode: Optional[str] -) -> Generator[tuple[str, Any], None, None]: +def _api_encode(data, api_mode: Optional[str]) -> Generator[tuple[str, Any], None, None]: for key, value in data.items(): if value is None: continue diff --git a/khipu_tools/_error.py b/khipu_tools/_error.py index 15e0753..158a31a 100644 --- a/khipu_tools/_error.py +++ b/khipu_tools/_error.py @@ -34,10 +34,7 @@ def __init__( try: body = cast(bytes, http_body).decode("utf-8") except BaseException: - body = ( - "" - ) + body = "" elif isinstance(http_body, str): body = http_body diff --git a/khipu_tools/_http_client.py b/khipu_tools/_http_client.py index 5378416..d64b695 100644 --- a/khipu_tools/_http_client.py +++ b/khipu_tools/_http_client.py @@ -54,9 +54,7 @@ def _should_retry( ): return False - def _retry_after_header( - self, response: Optional[tuple[Any, Any, Mapping[str, str]]] = None - ): + def _retry_after_header(self, response: Optional[tuple[Any, Any, Mapping[str, str]]] = None): return None def _sleep_time_seconds( @@ -173,9 +171,7 @@ def request( headers: Optional[Mapping[str, str]], post_data=None, ) -> tuple[bytes, int, Mapping[str, str]]: - return self._request_internal( - method, url, headers, post_data, is_streaming=False - ) + return self._request_internal(method, url, headers, post_data, is_streaming=False) def request_stream( self, @@ -184,9 +180,7 @@ def request_stream( headers: Optional[Mapping[str, str]], post_data=None, ) -> tuple[Any, int, Mapping[str, str]]: - return self._request_internal( - method, url, headers, post_data, is_streaming=True - ) + return self._request_internal(method, url, headers, post_data, is_streaming=True) @overload def _request_internal( @@ -332,9 +326,7 @@ async def request_async( ) -> tuple[bytes, int, Mapping[str, str]]: self.raise_async_client_import_error() - async def request_stream_async( - self, method: str, url: str, headers: Mapping[str, str], post_data=None - ): + async def request_stream_async(self, method: str, url: str, headers: Mapping[str, str], post_data=None): self.raise_async_client_import_error() async def close_async(self): diff --git a/khipu_tools/_khipu_object.py b/khipu_tools/_khipu_object.py index ac31d58..a10928f 100644 --- a/khipu_tools/_khipu_object.py +++ b/khipu_tools/_khipu_object.py @@ -28,9 +28,7 @@ @overload -def _compute_diff( - current: dict[str, Any], previous: Optional[dict[str, Any]] -) -> dict[str, Any]: ... +def _compute_diff(current: dict[str, Any], previous: Optional[dict[str, Any]]) -> dict[str, Any]: ... @overload @@ -176,8 +174,7 @@ def __getitem__(self, k: str) -> Any: "It was then wiped when refreshing the object with " "the result returned by Stripe's API, probably as a " "result of a save(). The attributes currently " - "available on this object are: %s" - % (k, k, ", ".join(list(self.keys()))) + "available on this object are: %s" % (k, k, ", ".join(list(self.keys()))) ) else: raise err diff --git a/khipu_tools/_list_object.py b/khipu_tools/_list_object.py index 1428304..b87bbe7 100644 --- a/khipu_tools/_list_object.py +++ b/khipu_tools/_list_object.py @@ -20,9 +20,7 @@ class ListObject(KhipuObject, Generic[T]): def _get_url_for_list(self) -> str: url = self.get("url") if not isinstance(url, str): - raise ValueError( - 'Cannot call .list on a list object without a string "url" property' - ) + raise ValueError('Cannot call .list on a list object without a string "url" property') return url def list(self, **params: Mapping[str, Any]) -> Self: @@ -96,10 +94,7 @@ def auto_paging_iter(self) -> Iterator[T]: page = self while True: - if ( - "ending_before" in self._retrieve_params - and "starting_after" not in self._retrieve_params - ): + if "ending_before" in self._retrieve_params and "starting_after" not in self._retrieve_params: yield from reversed(page) page = page.previous_page() else: @@ -147,9 +142,7 @@ def next_page(self, **params: Unpack[RequestOptions]) -> Self: **self._get_filters_for_next_page(params), ) - def _get_filters_for_previous_page( - self, params: RequestOptions - ) -> Mapping[str, Any]: + def _get_filters_for_previous_page(self, params: RequestOptions) -> Mapping[str, Any]: first_id = getattr(self.data[0], "id") if not first_id: raise ValueError("Unexpected: element in .data of list object had no id") diff --git a/khipu_tools/_listable_api_resource.py b/khipu_tools/_listable_api_resource.py index 10b8c2f..e164fca 100644 --- a/khipu_tools/_listable_api_resource.py +++ b/khipu_tools/_listable_api_resource.py @@ -24,8 +24,6 @@ def list(cls, **params) -> ListObject[T]: ) if not isinstance(result, ListObject): - raise TypeError( - f"Expected list object from API, got {type(result).__name__}" - ) + raise TypeError(f"Expected list object from API, got {type(result).__name__}") return result diff --git a/khipu_tools/_payments.py b/khipu_tools/_payments.py index 56ff0d3..3f89ee2 100644 --- a/khipu_tools/_payments.py +++ b/khipu_tools/_payments.py @@ -175,9 +175,7 @@ class PaymentInfo(RequestOptions): """Ignorar este campo.""" @classmethod - def create( - cls, **params: Unpack["Payments.PaymentParams"] - ) -> KhipuObject["Payments.PaymentCreateResponse"]: + def create(cls, **params: Unpack["Payments.PaymentParams"]) -> KhipuObject["Payments.PaymentCreateResponse"]: """ Crea un pago en Khipu y obtiene las URLs para redirección al usuario para que complete el pago. """ @@ -187,9 +185,7 @@ def create( params=params, ) if not isinstance(result, KhipuObject): - raise TypeError( - "Expected KhipuObject object from API, got %s" % (type(result).__name__) - ) + raise TypeError("Expected KhipuObject object from API, got %s" % (type(result).__name__)) return result @@ -203,9 +199,7 @@ def get(cls, **params: Unpack["Payments.PaymentInfo"]) -> KhipuObject["Payments" f"{cls.class_url()}/{params['payment_id']}", ) if not isinstance(result, KhipuObject): - raise TypeError( - "Expected KhipuObject object from API, got %s" % (type(result).__name__) - ) + raise TypeError("Expected KhipuObject object from API, got %s" % (type(result).__name__)) return result diff --git a/khipu_tools/_predict.py b/khipu_tools/_predict.py index dfc6543..fc98265 100644 --- a/khipu_tools/_predict.py +++ b/khipu_tools/_predict.py @@ -50,8 +50,6 @@ def get(cls, **params: Unpack["Predict.PredictParams"]) -> KhipuObject["Predict" params=params, ) if not isinstance(result, KhipuObject): - raise TypeError( - "Expected KhipuObject object from API, got %s" % (type(result).__name__) - ) + raise TypeError("Expected KhipuObject object from API, got %s" % (type(result).__name__)) return result diff --git a/khipu_tools/_util.py b/khipu_tools/_util.py index ebdf28b..652f1f2 100644 --- a/khipu_tools/_util.py +++ b/khipu_tools/_util.py @@ -225,10 +225,7 @@ def _convert_to_khipu_object( if ( params is not None and hasattr(obj, "object") - and ( - (getattr(obj, "object") == "list") - or (getattr(obj, "object") == "search_result") - ) + and ((getattr(obj, "object") == "list") or (getattr(obj, "object") == "search_result")) ): obj._retrieve_params = params