Skip to content

Commit

Permalink
refactor: Apply Ruff linter
Browse files Browse the repository at this point in the history
  • Loading branch information
otetard committed Sep 27, 2024
1 parent 0589100 commit fae85d1
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 16 deletions.
3 changes: 2 additions & 1 deletion sekoia_automation/aio/helpers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"""

import asyncio
from typing import Any, AsyncGenerator
from collections.abc import AsyncGenerator
from typing import Any


async def limit_concurrency(tasks: list, limit: int) -> AsyncGenerator[Any, None]:
Expand Down
3 changes: 1 addition & 2 deletions sekoia_automation/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
help="Sekoia.io's automation helper to generate playbook modules",
rich_markup_mode="markdown",
)
OptionalPath = Optional[Path]
OptionalStr = Optional[str]
OptionalStr = Optional[str] # noqa: UP007


@app.command(name="generate-files-from-code")
Expand Down
16 changes: 8 additions & 8 deletions sekoia_automation/http/aio/http_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import asyncio
from collections.abc import AsyncGenerator
from contextlib import asynccontextmanager
from typing import Any, Optional
from typing import Any

from aiohttp import ClientResponse, ClientResponseError, ClientSession
from aiohttp.web_response import Response
Expand Down Expand Up @@ -56,7 +56,7 @@ async def session(self) -> AsyncGenerator[ClientSession, None]:

@asynccontextmanager
async def get(
self, url: str, *args: Any, **kwargs: Optional[Any]
self, url: str, *args: Any, **kwargs: Any | None
) -> AsyncGenerator[ClientResponse, None]:
"""
Get callable.
Expand All @@ -74,7 +74,7 @@ async def get(

@asynccontextmanager
async def post(
self, url: str, *args: Any, **kwargs: Optional[Any]
self, url: str, *args: Any, **kwargs: Any | None
) -> AsyncGenerator[ClientResponse, None]:
"""
Post callable.
Expand All @@ -92,7 +92,7 @@ async def post(

@asynccontextmanager
async def put(
self, url: str, *args: Any, **kwargs: Optional[Any]
self, url: str, *args: Any, **kwargs: Any | None
) -> AsyncGenerator[ClientResponse, None]:
"""
Put callable.
Expand All @@ -110,7 +110,7 @@ async def put(

@asynccontextmanager
async def delete(
self, url: str, *args: Any, **kwargs: Optional[Any]
self, url: str, *args: Any, **kwargs: Any | None
) -> AsyncGenerator[ClientResponse, None]:
"""
Delete callable.
Expand All @@ -128,7 +128,7 @@ async def delete(

@asynccontextmanager
async def patch(
self, url: str, *args: Any, **kwargs: Optional[Any]
self, url: str, *args: Any, **kwargs: Any | None
) -> AsyncGenerator[ClientResponse, None]:
"""
Patch callable.
Expand All @@ -146,7 +146,7 @@ async def patch(

@asynccontextmanager
async def head(
self, url: str, *args: Any, **kwargs: Optional[Any]
self, url: str, *args: Any, **kwargs: Any | None
) -> AsyncGenerator[ClientResponse, None]:
"""
Head callable.
Expand All @@ -164,7 +164,7 @@ async def head(

@asynccontextmanager
async def request_retry(
self, method: str, url: str, *args: Any, **kwargs: Optional[Any]
self, method: str, url: str, *args: Any, **kwargs: Any | None
) -> AsyncGenerator[ClientResponse, None]:
"""
Request callable.
Expand Down
7 changes: 3 additions & 4 deletions sekoia_automation/scripts/action_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
import importlib.util
import json
import sys
import typing
from pathlib import Path
from typing import Any, Tuple
from typing import Any

from jsonschema import validate

Expand All @@ -28,7 +27,7 @@ def __init__(
if str(self.__module_path) not in sys.path:
sys.path.append(str(self.__module_path))

def load_class_from_path(self, path: Path | str, class_name: str) -> typing.Type:
def load_class_from_path(self, path: Path | str, class_name: str) -> type:
# Load the module
module_name = (
str(Path(path).resolve().relative_to(self.__root_path))
Expand Down Expand Up @@ -61,7 +60,7 @@ def find_file_with_module_item_class(self) -> Path:

def find_file_with_child_class(
self, parent_class_to_find: str
) -> Tuple[str | None, Path | None]:
) -> tuple[str | None, Path | None]:
for file_path in self.__module_path.rglob("*.py"):
with open(file_path) as f:
try:
Expand Down
2 changes: 1 addition & 1 deletion sekoia_automation/utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from collections.abc import Sequence
from functools import wraps
from inspect import get_annotations, getmro
from typing import Sequence

import sentry_sdk
from pydantic import BaseModel
Expand Down

0 comments on commit fae85d1

Please sign in to comment.