Skip to content

Commit

Permalink
Add missing return type annotation for special method `__init__ (#952)
Browse files Browse the repository at this point in the history
Fix Ruff - ANN204
  • Loading branch information
ogenstad committed Jul 1, 2024
1 parent cd47bdc commit 6659136
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion nornir/core/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class NornirSubTaskError(Exception):
Raised by nornir when a sub task managed by :meth:`nornir.core.Task.run` has failed
"""

def __init__(self, task: "Task", result: "Result"):
def __init__(self, task: "Task", result: "Result") -> None:
self.task = task
self.result = result

Expand Down
8 changes: 4 additions & 4 deletions nornir/core/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def __init__(
severity_level: int = DEFAULT_SEVERITY_LEVEL,
parent_task: Optional["Task"] = None,
**kwargs: str,
):
) -> None:
self.task = task
self.nornir = nornir
self.name = name or task.__name__
Expand Down Expand Up @@ -214,7 +214,7 @@ def __init__(
exception: Optional[BaseException] = None,
severity_level: int = DEFAULT_SEVERITY_LEVEL,
**kwargs: Any,
):
) -> None:
self.result = result
self.host = host
self.changed = changed
Expand Down Expand Up @@ -246,7 +246,7 @@ class MultiResult(List[Result]):
a particular device/task.
"""

def __init__(self, name: str):
def __init__(self, name: str) -> None:
self.name = name

def __getattr__(self, name: str) -> Any:
Expand Down Expand Up @@ -280,7 +280,7 @@ class AggregatedResult(Dict[str, MultiResult]):
You can access each individual result by doing ``my_aggr_result["hostname_of_device"]``.
"""

def __init__(self, name: str, **kwargs: MultiResult):
def __init__(self, name: str, **kwargs: MultiResult) -> None:
self.name = name
super().__init__(**kwargs)

Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,6 @@ ignore = [
# like this so that we can reactivate them one by one. Alternatively ignored after further #
# investigation if they are deemed to not make sense. #
##################################################################################################
"ANN204", # Missing return type annotation for special method `__init__`
"ANN401", # Dynamically typed expressions (typing.Any) are disallowed
"ARG002", # Unused method argument
"B028", # No explicit `stacklevel` keyword argument found
Expand Down
2 changes: 1 addition & 1 deletion tests/core/test_InitNornir.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def transform_func_with_options(host, a):


class InventoryTest:
def __init__(self, *args, **kwargs):
def __init__(self, *args, **kwargs) -> None:
pass

def load(self):
Expand Down

0 comments on commit 6659136

Please sign in to comment.