From 41f1b120894408738cd9ca6b72e836a96c2e8985 Mon Sep 17 00:00:00 2001 From: Sorin Sbarnea Date: Tue, 12 Nov 2024 12:37:57 +0000 Subject: [PATCH] Remove self type (#474) --- .pre-commit-config.yaml | 4 ++-- pyproject.toml | 5 ++--- src/ansible_dev_tools/cli.py | 8 ++++---- src/ansible_dev_tools/resources/server/creator_v1.py | 12 ++++++------ src/ansible_dev_tools/resources/server/creator_v2.py | 8 ++++---- src/ansible_dev_tools/subcommands/server.py | 10 +++++----- 6 files changed, 23 insertions(+), 24 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d8c0a170..622315c0 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -68,7 +68,7 @@ repos: - id: tox-ini-fmt - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.7.2 + rev: v0.7.3 hooks: - id: ruff args: @@ -84,7 +84,7 @@ repos: - id: black - repo: https://github.com/streetsidesoftware/cspell-cli - rev: v8.15.2 + rev: v8.16.0 hooks: - id: cspell name: Spell check with cspell diff --git a/pyproject.toml b/pyproject.toml index 167b9cfc..b5b6cade 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -347,9 +347,8 @@ external = [ "DOC" # pydoclint ] ignore = [ - # incompatible with ruff formatter - "COM812", # missing-space-after-comma - "ISC001" # implicit-str-concat + "COM812", # conflicts with ISC001 on format + "ISC001" # conflicts with COM812 on format ] select = ["ALL"] diff --git a/src/ansible_dev_tools/cli.py b/src/ansible_dev_tools/cli.py index e52403e6..e718d57e 100644 --- a/src/ansible_dev_tools/cli.py +++ b/src/ansible_dev_tools/cli.py @@ -18,15 +18,15 @@ class Cli: """The Cli class.""" - def __init__(self: Cli) -> None: + def __init__(self) -> None: """Initialize the CLI and parse CLI args.""" self.args: dict[str, Any] - def parse_args(self: Cli) -> None: + def parse_args(self) -> None: """Parse the command line arguments.""" self.args = vars(parse()) - def _run_subcommand(self: Cli, subcommand: str) -> None: + def _run_subcommand(self, subcommand: str) -> None: """Run the subcommand. Args: @@ -37,7 +37,7 @@ def _run_subcommand(self: Cli, subcommand: str) -> None: subcommand_cls = getattr(import_module(subcommand_module), subcommand_cls_name) subcommand_cls(**self.args).run() - def run(self: Cli) -> None: + def run(self) -> None: """Dispatch work to correct subcommand class.""" subcommand = self.args.pop("subcommand") if subcommand == "server": diff --git a/src/ansible_dev_tools/resources/server/creator_v1.py b/src/ansible_dev_tools/resources/server/creator_v1.py index 9af5dec3..02ac9f72 100644 --- a/src/ansible_dev_tools/resources/server/creator_v1.py +++ b/src/ansible_dev_tools/resources/server/creator_v1.py @@ -32,7 +32,7 @@ def create_tar_file(init_path: Path, tar_file: Path) -> None: class CreatorFrontendV1: """The creator frontend, handles requests from users.""" - def _response_from_tar(self: CreatorFrontendV1, tar_file: Path) -> FileResponse: + def _response_from_tar(self, tar_file: Path) -> FileResponse: """Create a FileResponse from a tar file. Args: @@ -51,7 +51,7 @@ def _response_from_tar(self: CreatorFrontendV1, tar_file: Path) -> FileResponse: return response def playbook( - self: CreatorFrontendV1, + self, request: HttpRequest, ) -> FileResponse | HttpResponse: """Create a new playbook project. @@ -78,7 +78,7 @@ def playbook( ) def collection( - self: CreatorFrontendV1, + self, request: HttpRequest, ) -> FileResponse | HttpResponse: """Create a new collection project. @@ -108,7 +108,7 @@ def collection( class CreatorOutput(Output): """The creator output.""" - def __init__(self: CreatorOutput, log_file: str) -> None: + def __init__(self, log_file: str) -> None: """Initialize the creator output. Convenience class to consistently define output with a changing temporary directory. @@ -128,7 +128,7 @@ def __init__(self: CreatorOutput, log_file: str) -> None: class CreatorBackend: """The creator wrapper, handles interaction with the python creator project.""" - def __init__(self: CreatorBackend, tmp_dir: Path) -> None: + def __init__(self, tmp_dir: Path) -> None: """Initialize the creator. Args: @@ -136,7 +136,7 @@ def __init__(self: CreatorBackend, tmp_dir: Path) -> None: """ self.tmp_dir = tmp_dir - def collection(self: CreatorBackend, collection: str, project: str) -> Path: + def collection(self, collection: str, project: str) -> Path: """Scaffold a collection. Args: diff --git a/src/ansible_dev_tools/resources/server/creator_v2.py b/src/ansible_dev_tools/resources/server/creator_v2.py index 8f88373a..b9661b46 100644 --- a/src/ansible_dev_tools/resources/server/creator_v2.py +++ b/src/ansible_dev_tools/resources/server/creator_v2.py @@ -32,7 +32,7 @@ def create_tar_file(init_path: Path, tar_file: Path) -> None: class CreatorFrontendV2: """The creator frontend, handles requests from users.""" - def _response_from_tar(self: CreatorFrontendV2, tar_file: Path) -> FileResponse: + def _response_from_tar(self, tar_file: Path) -> FileResponse: """Create a FileResponse from a tar file. Args: @@ -108,7 +108,7 @@ def collection( class CreatorOutput(Output): """The creator output.""" - def __init__(self: CreatorOutput, log_file: str) -> None: + def __init__(self, log_file: str) -> None: """Initialize the creator output. Convenience class to consistently define output with a changing temporary directory. @@ -128,7 +128,7 @@ def __init__(self: CreatorOutput, log_file: str) -> None: class CreatorBackend: """The creator wrapper, handles interaction with the python creator project.""" - def __init__(self: CreatorBackend, tmp_dir: Path) -> None: + def __init__(self, tmp_dir: Path) -> None: """Initialize the creator. Args: @@ -136,7 +136,7 @@ def __init__(self: CreatorBackend, tmp_dir: Path) -> None: """ self.tmp_dir = tmp_dir - def collection(self: CreatorBackend, collection: str, project: str) -> Path: + def collection(self, collection: str, project: str) -> Path: """Scaffold a collection. Args: diff --git a/src/ansible_dev_tools/subcommands/server.py b/src/ansible_dev_tools/subcommands/server.py index 09011d59..7d523a59 100644 --- a/src/ansible_dev_tools/subcommands/server.py +++ b/src/ansible_dev_tools/subcommands/server.py @@ -32,7 +32,7 @@ class AdtServerApp(BaseApplication): # type: ignore[misc] """Custom application to integrate Gunicorn with the django WSGI app.""" # pylint: disable=abstract-method - def __init__(self: AdtServerApp, app: WSGIHandler, options: dict[str, str]) -> None: + def __init__(self, app: WSGIHandler, options: dict[str, str]) -> None: """Initialize the application. Args: @@ -43,7 +43,7 @@ def __init__(self: AdtServerApp, app: WSGIHandler, options: dict[str, str]) -> N self.application = app super().__init__() - def load_config(self: AdtServerApp) -> None: + def load_config(self) -> None: """Load configuration for gunicorn.""" config = { key: value @@ -53,7 +53,7 @@ def load_config(self: AdtServerApp) -> None: for key, value in config.items(): self.cfg.set(key.lower(), value) - def load(self: AdtServerApp) -> WSGIHandler: + def load(self) -> WSGIHandler: """Load application. Returns: @@ -65,7 +65,7 @@ def load(self: AdtServerApp) -> WSGIHandler: class Server: """Ansible Devtools server implementation.""" - def __init__(self: Server, port: str, debug: bool) -> None: # noqa: FBT001 + def __init__(self, port: str, debug: bool) -> None: # noqa: FBT001 """Initialize an AdtServer object. Args: @@ -90,7 +90,7 @@ def __init__(self: Server, port: str, debug: bool) -> None: # noqa: FBT001 setup() self.application = get_wsgi_application() - def run(self: Server) -> None: + def run(self) -> None: """Start the server.""" options = {"bind": f"0.0.0.0:{self.port}"} if self.debug: