Skip to content

Commit

Permalink
Fix some typing issues
Browse files Browse the repository at this point in the history
  • Loading branch information
bjoernricks committed Jun 5, 2024
1 parent 22fb65e commit 2ba6b61
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
14 changes: 7 additions & 7 deletions gvm/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from lxml import etree

from .errors import GvmError, GvmResponseError, GvmServerError
from .xml import create_parser
from .xml import Element, create_parser


class EtreeTransform:
Expand All @@ -19,18 +19,18 @@ class EtreeTransform:
def __init__(self):
self._parser = create_parser()

def _convert_response(self, response: str) -> etree.Element:
def _convert_response(self, response: str) -> Element:
return etree.XML(response, parser=self._parser)

def __call__(self, response: str) -> etree.Element:
def __call__(self, response: str) -> Element:
return self._convert_response(response)


def check_command_status(root: etree.Element):
def check_command_status(root: Element):
status = root.get("status")

if status is None:
raise GvmServerError("No status in response.", root)
raise GvmServerError("No status in response.", str(root))

if status[0] == "4":
raise GvmResponseError(status=status, message=root.get("status_text"))
Expand All @@ -46,7 +46,7 @@ class CheckCommandTransform(EtreeTransform):
response was an error response
"""

def __call__(self, response: str) -> str:
def __call__(self, response: str) -> str: # type: ignore[override]
root = self._convert_response(response)

check_command_status(root)
Expand All @@ -60,7 +60,7 @@ class EtreeCheckCommandTransform(EtreeTransform):
response was an error response
"""

def __call__(self, response: str) -> etree.Element:
def __call__(self, response: str) -> Element:
root = self._convert_response(response)

check_command_status(root)
Expand Down
4 changes: 2 additions & 2 deletions gvm/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ class TypesDict(dict):
"""For dot.notation access to dictionary attributes"""

__getattr__ = dict.get
__setattr__ = dict.__setitem__
__delattr__ = dict.__delitem__
__setattr__ = dict.__setitem__ # type: ignore[assignment]
__delattr__ = dict.__delitem__ # type: ignore[assignment]


def deprecation(message: str):
Expand Down

0 comments on commit 2ba6b61

Please sign in to comment.