Skip to content

Commit

Permalink
Remove self type (#474)
Browse files Browse the repository at this point in the history
  • Loading branch information
ssbarnea authored Nov 12, 2024
1 parent 7f98ffa commit 41f1b12
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 24 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down
5 changes: 2 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]

Expand Down
8 changes: 4 additions & 4 deletions src/ansible_dev_tools/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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":
Expand Down
12 changes: 6 additions & 6 deletions src/ansible_dev_tools/resources/server/creator_v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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.
Expand All @@ -78,7 +78,7 @@ def playbook(
)

def collection(
self: CreatorFrontendV1,
self,
request: HttpRequest,
) -> FileResponse | HttpResponse:
"""Create a new collection project.
Expand Down Expand Up @@ -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.
Expand All @@ -128,15 +128,15 @@ 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:
tmp_dir: The temporary directory.
"""
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:
Expand Down
8 changes: 4 additions & 4 deletions src/ansible_dev_tools/resources/server/creator_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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.
Expand All @@ -128,15 +128,15 @@ 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:
tmp_dir: The temporary directory.
"""
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:
Expand Down
10 changes: 5 additions & 5 deletions src/ansible_dev_tools/subcommands/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand Down

0 comments on commit 41f1b12

Please sign in to comment.