python-gvm 26.11.1__py3-none-any.whl → 26.11.2.dev1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (94) hide show
  1. gvm/__version__.py +1 -1
  2. gvm/_enum.py +5 -5
  3. gvm/connections/__init__.py +3 -3
  4. gvm/connections/_connection.py +3 -3
  5. gvm/connections/_debug.py +1 -1
  6. gvm/connections/_ssh.py +14 -15
  7. gvm/connections/_tls.py +7 -8
  8. gvm/connections/_unix.py +2 -3
  9. gvm/errors.py +14 -20
  10. gvm/protocols/_protocol.py +6 -5
  11. gvm/protocols/core/_connection.py +8 -8
  12. gvm/protocols/core/_response.py +4 -4
  13. gvm/protocols/gmp/__init__.py +2 -2
  14. gvm/protocols/gmp/_gmp.py +8 -8
  15. gvm/protocols/gmp/_gmp224.py +496 -505
  16. gvm/protocols/gmp/_gmp225.py +1 -3
  17. gvm/protocols/gmp/_gmp226.py +46 -46
  18. gvm/protocols/gmp/_gmp227.py +21 -23
  19. gvm/protocols/gmp/_gmpnext.py +169 -104
  20. gvm/protocols/gmp/requests/_entity_id.py +1 -2
  21. gvm/protocols/gmp/requests/next/__init__.py +15 -11
  22. gvm/protocols/gmp/requests/next/_agent_groups.py +8 -9
  23. gvm/protocols/gmp/requests/next/_agent_installers.py +4 -6
  24. gvm/protocols/gmp/requests/next/_agents.py +14 -13
  25. gvm/protocols/gmp/requests/next/_credential_stores.py +15 -16
  26. gvm/protocols/gmp/requests/next/_credentials.py +13 -14
  27. gvm/protocols/gmp/requests/next/_integration_configs.py +110 -0
  28. gvm/protocols/gmp/requests/next/_oci_image_targets.py +12 -13
  29. gvm/protocols/gmp/requests/next/_tasks.py +53 -50
  30. gvm/protocols/gmp/requests/v224/__init__.py +9 -9
  31. gvm/protocols/gmp/requests/v224/_aggregates.py +13 -14
  32. gvm/protocols/gmp/requests/v224/_alerts.py +26 -27
  33. gvm/protocols/gmp/requests/v224/_audits.py +26 -27
  34. gvm/protocols/gmp/requests/v224/_auth.py +0 -1
  35. gvm/protocols/gmp/requests/v224/_cert_bund_advisories.py +4 -6
  36. gvm/protocols/gmp/requests/v224/_cpes.py +4 -6
  37. gvm/protocols/gmp/requests/v224/_credentials.py +52 -53
  38. gvm/protocols/gmp/requests/v224/_cves.py +4 -6
  39. gvm/protocols/gmp/requests/v224/_dfn_cert_advisories.py +4 -6
  40. gvm/protocols/gmp/requests/v224/_entity_type.py +1 -1
  41. gvm/protocols/gmp/requests/v224/_feed.py +1 -2
  42. gvm/protocols/gmp/requests/v224/_filters.py +14 -14
  43. gvm/protocols/gmp/requests/v224/_groups.py +10 -11
  44. gvm/protocols/gmp/requests/v224/_help.py +2 -3
  45. gvm/protocols/gmp/requests/v224/_hosts.py +6 -10
  46. gvm/protocols/gmp/requests/v224/_notes.py +18 -19
  47. gvm/protocols/gmp/requests/v224/_nvts.py +26 -30
  48. gvm/protocols/gmp/requests/v224/_operating_systems.py +5 -7
  49. gvm/protocols/gmp/requests/v224/_overrides.py +20 -22
  50. gvm/protocols/gmp/requests/v224/_permissions.py +14 -16
  51. gvm/protocols/gmp/requests/v224/_policies.py +16 -17
  52. gvm/protocols/gmp/requests/v224/_port_lists.py +10 -11
  53. gvm/protocols/gmp/requests/v224/_report_formats.py +17 -19
  54. gvm/protocols/gmp/requests/v224/_reports.py +13 -15
  55. gvm/protocols/gmp/requests/v224/_results.py +6 -8
  56. gvm/protocols/gmp/requests/v224/_roles.py +9 -11
  57. gvm/protocols/gmp/requests/v224/_scan_configs.py +19 -20
  58. gvm/protocols/gmp/requests/v224/_scanners.py +17 -17
  59. gvm/protocols/gmp/requests/v224/_schedules.py +16 -20
  60. gvm/protocols/gmp/requests/v224/_secinfo.py +4 -5
  61. gvm/protocols/gmp/requests/v224/_system_reports.py +6 -7
  62. gvm/protocols/gmp/requests/v224/_tags.py +18 -20
  63. gvm/protocols/gmp/requests/v224/_targets.py +37 -37
  64. gvm/protocols/gmp/requests/v224/_tasks.py +30 -31
  65. gvm/protocols/gmp/requests/v224/_tickets.py +9 -11
  66. gvm/protocols/gmp/requests/v224/_tls_certificates.py +9 -10
  67. gvm/protocols/gmp/requests/v224/_user_settings.py +4 -5
  68. gvm/protocols/gmp/requests/v224/_users.py +18 -20
  69. gvm/protocols/gmp/requests/v224/_vulnerabilities.py +2 -3
  70. gvm/protocols/gmp/requests/v225/__init__.py +9 -9
  71. gvm/protocols/gmp/requests/v225/_resource_names.py +3 -4
  72. gvm/protocols/gmp/requests/v226/__init__.py +10 -10
  73. gvm/protocols/gmp/requests/v226/_audit_reports.py +12 -14
  74. gvm/protocols/gmp/requests/v226/_filters.py +15 -15
  75. gvm/protocols/gmp/requests/v226/_report_configs.py +23 -16
  76. gvm/protocols/gmp/requests/v226/_reports.py +14 -16
  77. gvm/protocols/gmp/requests/v226/_resource_names.py +3 -4
  78. gvm/protocols/gmp/requests/v227/__init__.py +10 -10
  79. gvm/protocols/gmp/requests/v227/_scanners.py +21 -21
  80. gvm/protocols/http/openvasd/_client.py +8 -9
  81. gvm/protocols/http/openvasd/_metadata.py +2 -3
  82. gvm/protocols/http/openvasd/_openvasd1.py +5 -7
  83. gvm/protocols/http/openvasd/_scans.py +13 -13
  84. gvm/protocols/latest.py +2 -2
  85. gvm/protocols/next.py +2 -2
  86. gvm/protocols/ospv1.py +28 -27
  87. gvm/transforms.py +1 -0
  88. gvm/utils.py +18 -23
  89. gvm/xml.py +11 -11
  90. {python_gvm-26.11.1.dist-info → python_gvm-26.11.2.dev1.dist-info}/METADATA +16 -29
  91. python_gvm-26.11.2.dev1.dist-info/RECORD +107 -0
  92. {python_gvm-26.11.1.dist-info → python_gvm-26.11.2.dev1.dist-info}/WHEEL +1 -1
  93. python_gvm-26.11.1.dist-info/RECORD +0 -107
  94. python_gvm-26.11.1.dist-info/licenses/LICENSE +0 -674
gvm/__version__.py CHANGED
@@ -2,4 +2,4 @@
2
2
 
3
3
  # THIS IS AN AUTOGENERATED FILE. DO NOT TOUCH!
4
4
 
5
- __version__ = "26.11.1"
5
+ __version__ = "27.0.0"
gvm/_enum.py CHANGED
@@ -4,7 +4,7 @@
4
4
  #
5
5
 
6
6
  from enum import Enum as PythonEnum
7
- from typing import Any, Optional, Type, TypeVar
7
+ from typing import Any, TypeVar
8
8
 
9
9
  from gvm.errors import InvalidArgument
10
10
 
@@ -17,16 +17,16 @@ class Enum(PythonEnum):
17
17
  """
18
18
 
19
19
  @classmethod
20
- def _missing_(cls: Type[Self], value: Any) -> Optional[Self]:
20
+ def _missing_(cls: type[Self], value: Any) -> Self | None:
21
21
  if isinstance(value, PythonEnum):
22
22
  return cls.from_string(value.name)
23
23
  return cls.from_string(str(value) if value else None)
24
24
 
25
25
  @classmethod
26
26
  def from_string(
27
- cls: Type[Self],
28
- value: Optional[str],
29
- ) -> Optional[Self]:
27
+ cls: type[Self],
28
+ value: str | None,
29
+ ) -> Self | None:
30
30
  """
31
31
  Convert a string value into an Enum instance
32
32
 
@@ -16,14 +16,14 @@ from ._tls import DEFAULT_GVM_PORT, TLSConnection
16
16
  from ._unix import DEFAULT_UNIX_SOCKET_PATH, UnixSocketConnection
17
17
 
18
18
  __all__ = (
19
- "DEFAULT_TIMEOUT",
20
- "DEFAULT_UNIX_SOCKET_PATH",
21
19
  "DEFAULT_GVM_PORT",
22
20
  "DEFAULT_HOSTNAME",
23
21
  "DEFAULT_KNOWN_HOSTS_FILE",
24
22
  "DEFAULT_SSH_PASSWORD",
25
- "DEFAULT_SSH_USERNAME",
26
23
  "DEFAULT_SSH_PORT",
24
+ "DEFAULT_SSH_USERNAME",
25
+ "DEFAULT_TIMEOUT",
26
+ "DEFAULT_UNIX_SOCKET_PATH",
27
27
  "DebugConnection",
28
28
  "GvmConnection",
29
29
  "SSHConnection",
@@ -6,7 +6,7 @@ import logging
6
6
  import socket as socketlib
7
7
  from abc import ABC, abstractmethod
8
8
  from time import time
9
- from typing import Optional, Protocol, Union, runtime_checkable
9
+ from typing import Protocol, runtime_checkable
10
10
 
11
11
  from gvm.errors import GvmError
12
12
 
@@ -62,8 +62,8 @@ class AbstractGvmConnection(ABC):
62
62
  wait indefinitely
63
63
  """
64
64
 
65
- def __init__(self, timeout: Optional[Union[int, float]] = DEFAULT_TIMEOUT):
66
- self._socket: Optional[socketlib.SocketType] = None
65
+ def __init__(self, timeout: int | float | None = DEFAULT_TIMEOUT):
66
+ self._socket: socketlib.SocketType | None = None
67
67
  self._timeout = timeout if timeout is not None else DEFAULT_TIMEOUT
68
68
 
69
69
  def _read(self) -> bytes:
gvm/connections/_debug.py CHANGED
@@ -26,7 +26,7 @@ class DebugConnection:
26
26
 
27
27
  logging.basicConfig(level=logging.DEBUG)
28
28
 
29
- socket_connection = UnixSocketConnection(path='/var/run/gvm.sock')
29
+ socket_connection = UnixSocketConnection(path="/var/run/gvm.sock")
30
30
  connection = DebugConnection(socket_connection)
31
31
  gmp = GMP(connection=connection)
32
32
  """
gvm/connections/_ssh.py CHANGED
@@ -8,10 +8,11 @@ import hashlib
8
8
  import logging
9
9
  import socket as socketlib
10
10
  import sys
11
+ from collections.abc import Callable
11
12
  from os import PathLike
12
13
  from pathlib import Path
13
14
  from time import time
14
- from typing import Any, Callable, Optional, TextIO, Union
15
+ from typing import Any, TextIO
15
16
 
16
17
  import paramiko
17
18
  import paramiko.ssh_exception
@@ -39,16 +40,16 @@ class SSHConnection:
39
40
  def __init__(
40
41
  self,
41
42
  *,
42
- timeout: Optional[Union[int, float]] = DEFAULT_TIMEOUT,
43
- hostname: Optional[str] = DEFAULT_HOSTNAME,
44
- port: Optional[int] = DEFAULT_SSH_PORT,
45
- username: Optional[str] = DEFAULT_SSH_USERNAME,
46
- password: Optional[str] = DEFAULT_SSH_PASSWORD,
47
- known_hosts_file: Optional[Union[str, PathLike]] = None,
48
- auto_accept_host: Optional[bool] = None,
43
+ timeout: int | float | None = DEFAULT_TIMEOUT,
44
+ hostname: str | None = DEFAULT_HOSTNAME,
45
+ port: int | None = DEFAULT_SSH_PORT,
46
+ username: str | None = DEFAULT_SSH_USERNAME,
47
+ password: str | None = DEFAULT_SSH_PASSWORD,
48
+ known_hosts_file: str | PathLike | None = None,
49
+ auto_accept_host: bool | None = None,
49
50
  file: TextIO = sys.stdout,
50
- input: Callable[[], str] = input,
51
- exit: Callable[[str], Any] = sys.exit,
51
+ input: Callable[[], str] = input, # noqa: A002
52
+ exit: Callable[[str], Any] = sys.exit, # noqa: A002
52
53
  ) -> None:
53
54
  """
54
55
  Create a new SSH connection instance.
@@ -61,7 +62,7 @@ class SSHConnection:
61
62
  username: Username to use for SSH login. Default is "gmp".
62
63
  password: Password to use for SSH login. Default is "".
63
64
  """
64
- self._client: Optional[paramiko.SSHClient] = None
65
+ self._client: paramiko.SSHClient | None = None
65
66
  self.hostname = hostname if hostname is not None else DEFAULT_HOSTNAME
66
67
  self.port = int(port) if port is not None else DEFAULT_SSH_PORT
67
68
  self.username = (
@@ -118,8 +119,7 @@ class SSHConnection:
118
119
  key_type = key.get_name().replace("ssh-", "").upper()
119
120
 
120
121
  logger.info(
121
- "Warning: Permanently added '%s' (%s) to "
122
- "the list of known hosts.",
122
+ "Warning: Permanently added '%s' (%s) to the list of known hosts.",
123
123
  self.hostname,
124
124
  key_type,
125
125
  )
@@ -135,8 +135,7 @@ class SSHConnection:
135
135
  key_type = key.get_name().replace("ssh-", "").upper()
136
136
 
137
137
  print(
138
- f"The authenticity of host '{self.hostname}' can't "
139
- "be established.",
138
+ f"The authenticity of host '{self.hostname}' can't be established.",
140
139
  file=self._file,
141
140
  )
142
141
  print(
gvm/connections/_tls.py CHANGED
@@ -5,7 +5,6 @@
5
5
  import logging
6
6
  import socket as socketlib
7
7
  import ssl
8
- from typing import Optional, Union
9
8
 
10
9
  from ._connection import DEFAULT_TIMEOUT, AbstractGvmConnection
11
10
 
@@ -25,13 +24,13 @@ class TLSConnection(AbstractGvmConnection):
25
24
  def __init__(
26
25
  self,
27
26
  *,
28
- certfile: Optional[str] = None,
29
- cafile: Optional[str] = None,
30
- keyfile: Optional[str] = None,
31
- hostname: Optional[str] = DEFAULT_HOSTNAME,
32
- port: Optional[int] = DEFAULT_GVM_PORT,
33
- password: Optional[str] = None,
34
- timeout: Optional[Union[int, float]] = DEFAULT_TIMEOUT,
27
+ certfile: str | None = None,
28
+ cafile: str | None = None,
29
+ keyfile: str | None = None,
30
+ hostname: str | None = DEFAULT_HOSTNAME,
31
+ port: int | None = DEFAULT_GVM_PORT,
32
+ password: str | None = None,
33
+ timeout: int | float | None = DEFAULT_TIMEOUT,
35
34
  ) -> None:
36
35
  """
37
36
  Create a new TLSConnection instance.
gvm/connections/_unix.py CHANGED
@@ -4,7 +4,6 @@
4
4
 
5
5
  import socket as socketlib
6
6
  from os import PathLike, fspath
7
- from typing import Optional, Union
8
7
 
9
8
  from gvm.errors import GvmError
10
9
 
@@ -22,8 +21,8 @@ class UnixSocketConnection(AbstractGvmConnection):
22
21
  def __init__(
23
22
  self,
24
23
  *,
25
- path: Optional[Union[str, PathLike[str]]] = DEFAULT_UNIX_SOCKET_PATH,
26
- timeout: Optional[Union[int, float]] = DEFAULT_TIMEOUT,
24
+ path: str | PathLike[str] | None = DEFAULT_UNIX_SOCKET_PATH,
25
+ timeout: int | float | None = DEFAULT_TIMEOUT,
27
26
  ) -> None:
28
27
  """
29
28
  Create a new UnixSocketConnection instance.
gvm/errors.py CHANGED
@@ -6,8 +6,6 @@
6
6
  Module for GVM errors
7
7
  """
8
8
 
9
- from typing import Optional
10
-
11
9
 
12
10
  class GvmError(Exception):
13
11
  """An exception for gvm errors
@@ -15,7 +13,7 @@ class GvmError(Exception):
15
13
  Base class for all exceptions originating in python-gvm.
16
14
  """
17
15
 
18
- def __init__(self, message: Optional[str], *args):
16
+ def __init__(self, message: str | None, *args):
19
17
  super().__init__(message, *args)
20
18
  self.message = message
21
19
 
@@ -44,9 +42,7 @@ class GvmServerError(GvmError):
44
42
  and function
45
43
  """
46
44
 
47
- def __init__(
48
- self, status: Optional[str] = None, message: Optional[str] = None
49
- ):
45
+ def __init__(self, status: str | None = None, message: str | None = None):
50
46
  super().__init__(message, status)
51
47
  self.status = status
52
48
 
@@ -71,9 +67,7 @@ class GvmResponseError(GvmClientError):
71
67
  and function
72
68
  """
73
69
 
74
- def __init__(
75
- self, status: Optional[str] = None, message: Optional[str] = None
76
- ):
70
+ def __init__(self, status: str | None = None, message: str | None = None):
77
71
  super().__init__(message, status)
78
72
  self.status = status
79
73
 
@@ -87,7 +81,7 @@ class GvmResponseError(GvmClientError):
87
81
  )
88
82
 
89
83
 
90
- class InvalidArgument(GvmError):
84
+ class InvalidArgument(GvmError): # noqa: N818
91
85
  """Raised if an invalid argument/parameter is passed
92
86
 
93
87
  Derives from :py:class:`GvmError`
@@ -101,10 +95,10 @@ class InvalidArgument(GvmError):
101
95
 
102
96
  def __init__(
103
97
  self,
104
- message: Optional[str] = None,
98
+ message: str | None = None,
105
99
  *,
106
- argument: Optional[str] = None,
107
- function: Optional[str] = None,
100
+ argument: str | None = None,
101
+ function: str | None = None,
108
102
  ):
109
103
  super().__init__(message, argument, function)
110
104
  self.argument = argument
@@ -123,7 +117,7 @@ class InvalidArgument(GvmError):
123
117
  return f"Invalid argument {self.argument} for {self.function}"
124
118
 
125
119
 
126
- class InvalidArgumentType(GvmError):
120
+ class InvalidArgumentType(GvmError): # noqa: N818
127
121
  """Raised if a passed argument has an invalid type
128
122
 
129
123
  Derives from :py:class:`GvmError`
@@ -138,8 +132,8 @@ class InvalidArgumentType(GvmError):
138
132
  self,
139
133
  argument: str,
140
134
  *,
141
- arg_type: Optional[str] = None,
142
- function: Optional[str] = None,
135
+ arg_type: str | None = None,
136
+ function: str | None = None,
143
137
  ):
144
138
  super().__init__(None)
145
139
  self.argument = argument
@@ -165,7 +159,7 @@ class InvalidArgumentType(GvmError):
165
159
  return f"Invalid argument type for argument {self.argument}."
166
160
 
167
161
 
168
- class RequiredArgument(GvmError):
162
+ class RequiredArgument(GvmError): # noqa: N818
169
163
  """Raised if a required argument/parameter is missing
170
164
 
171
165
  Derives from :py:class:`GvmError`
@@ -179,10 +173,10 @@ class RequiredArgument(GvmError):
179
173
 
180
174
  def __init__(
181
175
  self,
182
- message: Optional[str] = None,
176
+ message: str | None = None,
183
177
  *,
184
- argument: Optional[str] = None,
185
- function: Optional[str] = None,
178
+ argument: str | None = None,
179
+ function: str | None = None,
186
180
  ):
187
181
  super().__init__(message, argument, function)
188
182
  self.argument = argument
@@ -2,8 +2,9 @@
2
2
  #
3
3
  # SPDX-License-Identifier: GPL-3.0-or-later
4
4
 
5
+ from collections.abc import Callable
5
6
  from types import TracebackType
6
- from typing import Callable, Generic, Optional, Type, TypeVar
7
+ from typing import Generic, TypeVar
7
8
 
8
9
  from gvm.connections import GvmConnection
9
10
 
@@ -50,9 +51,9 @@ class GvmProtocol(Generic[T]):
50
51
 
51
52
  def __exit__(
52
53
  self,
53
- exc_type: Optional[Type[BaseException]],
54
- exc_value: Optional[BaseException],
55
- traceback: Optional[TracebackType],
54
+ exc_type: type[BaseException] | None,
55
+ exc_value: BaseException | None,
56
+ traceback: TracebackType | None,
56
57
  ) -> None:
57
58
  self.disconnect()
58
59
 
@@ -126,7 +127,7 @@ class GvmProtocol(Generic[T]):
126
127
  try:
127
128
  send_data = self._protocol.send(request)
128
129
  self._send(send_data)
129
- response: Optional[Response] = None
130
+ response: Response | None = None
130
131
  while not response:
131
132
  received_data = self._read()
132
133
  response = self._protocol.receive_data(received_data)
@@ -2,7 +2,7 @@
2
2
  #
3
3
  # SPDX-License-Identifier: GPL-3.0-or-later
4
4
 
5
- from typing import AnyStr, Optional, Protocol
5
+ from typing import AnyStr, Protocol
6
6
 
7
7
  from lxml import etree
8
8
 
@@ -18,7 +18,7 @@ class XmlReader:
18
18
  """
19
19
 
20
20
  def start_xml(self) -> None:
21
- self._first_element: Optional[etree._Element] = None
21
+ self._first_element: etree._Element | None = None
22
22
  # act on start and end element events and
23
23
  # allow huge text data (for report content)
24
24
  self._parser = etree.XMLPullParser(
@@ -60,7 +60,7 @@ class InvalidStateError(GvmError):
60
60
  class State(Protocol):
61
61
  def __set_context__(self, context: "Context") -> None: ...
62
62
  def send(self, request: Request) -> bytes: ...
63
- def receive_data(self, data: bytes) -> Optional[Response]: ...
63
+ def receive_data(self, data: bytes) -> Response | None: ...
64
64
  def close(self) -> None: ...
65
65
 
66
66
 
@@ -83,7 +83,7 @@ class InitialState(AbstractState):
83
83
  self.set_next_state(AwaitingResponseState(request))
84
84
  return bytes(request)
85
85
 
86
- def receive_data(self, data: bytes) -> Optional[Response]:
86
+ def receive_data(self, data: bytes) -> Response | None:
87
87
  raise InvalidStateError()
88
88
 
89
89
  def close(self) -> None:
@@ -101,7 +101,7 @@ class AwaitingResponseState(AbstractState):
101
101
  def close(self) -> None:
102
102
  self.set_next_state(InitialState())
103
103
 
104
- def receive_data(self, data: bytes) -> Optional[Response]:
104
+ def receive_data(self, data: bytes) -> Response | None:
105
105
  next_state = ReceivingDataState(self._request)
106
106
  self.set_next_state(next_state)
107
107
  return next_state.receive_data(data)
@@ -118,7 +118,7 @@ class ErrorState(AbstractState):
118
118
  def close(self) -> None:
119
119
  self.set_next_state(InitialState())
120
120
 
121
- def receive_data(self, data: bytes) -> Optional[Response]:
121
+ def receive_data(self, data: bytes) -> Response | None:
122
122
  raise InvalidStateError(self.message)
123
123
 
124
124
 
@@ -135,7 +135,7 @@ class ReceivingDataState(AbstractState):
135
135
  def close(self) -> None:
136
136
  self.set_next_state(InitialState())
137
137
 
138
- def receive_data(self, data: bytes) -> Optional[Response]:
138
+ def receive_data(self, data: bytes) -> Response | None:
139
139
  self._data += data
140
140
  try:
141
141
  self._reader.feed_xml(data)
@@ -174,7 +174,7 @@ class Connection:
174
174
  """
175
175
  return self._state.send(request)
176
176
 
177
- def receive_data(self, data: bytes) -> Optional[Response]:
177
+ def receive_data(self, data: bytes) -> Response | None:
178
178
  """
179
179
  Feed received data a response is complete
180
180
 
@@ -3,7 +3,7 @@
3
3
  # SPDX-License-Identifier: GPL-3.0-or-later
4
4
 
5
5
  from functools import cached_property
6
- from typing import Optional, TypeVar
6
+ from typing import TypeVar
7
7
 
8
8
  from gvm.errors import GvmError
9
9
  from gvm.xml import Element, parse_xml
@@ -18,7 +18,7 @@ class StatusError(GvmError):
18
18
  May be raised when calling `response.raise_for_status()`
19
19
  """
20
20
 
21
- def __init__(self, message: Optional[str], *args, response: "Response"):
21
+ def __init__(self, message: str | None, *args, response: "Response"):
22
22
  super().__init__(message, *args)
23
23
  self.response = response
24
24
  self.request = response.request
@@ -42,7 +42,7 @@ class Response:
42
42
  """
43
43
  self._request = request
44
44
  self._data = data
45
- self.__xml: Optional[Element] = None
45
+ self.__xml: Element | None = None
46
46
 
47
47
  def __root_element(self) -> Element:
48
48
  if self.__xml is None:
@@ -72,7 +72,7 @@ class Response:
72
72
  return self._request
73
73
 
74
74
  @cached_property
75
- def status_code(self) -> Optional[int]:
75
+ def status_code(self) -> int | None:
76
76
  """
77
77
  The status code of the response
78
78
 
@@ -30,10 +30,10 @@ Gmp = GMP # for backwards compatibility
30
30
 
31
31
  __all__ = (
32
32
  "GMP",
33
- "Gmp",
33
+ "GMPNext",
34
34
  "GMPv224",
35
35
  "GMPv225",
36
36
  "GMPv226",
37
37
  "GMPv227",
38
- "GMPNext",
38
+ "Gmp",
39
39
  )
gvm/protocols/gmp/_gmp.py CHANGED
@@ -3,8 +3,8 @@
3
3
  # SPDX-License-Identifier: GPL-3.0-or-later
4
4
 
5
5
  import warnings
6
+ from collections.abc import Callable
6
7
  from types import TracebackType
7
- from typing import Callable, Optional, Type, Union
8
8
 
9
9
  from gvm.__version__ import __version__
10
10
  from gvm.connections import GvmConnection
@@ -19,9 +19,9 @@ from ._gmp227 import GMPv227
19
19
  from ._gmpnext import GMPNext
20
20
  from .requests import Version
21
21
 
22
- SUPPORTED_GMP_VERSIONS = Union[
23
- GMPv224[T], GMPv225[T], GMPv226[T], GMPv227[T], GMPNext[T]
24
- ]
22
+ SUPPORTED_GMP_VERSIONS = (
23
+ GMPv224[T] | GMPv225[T] | GMPv226[T] | GMPv227[T] | GMPNext[T]
24
+ )
25
25
  _SUPPORTED_GMP_VERSION_STRINGS = ["22.4", "22.5", "22.6", "22.7", "22.8"]
26
26
 
27
27
 
@@ -67,7 +67,7 @@ class GMP(GvmProtocol[T]):
67
67
  See :mod:`gvm.transforms` for existing transforms.
68
68
  """
69
69
  super().__init__(connection, transform=transform)
70
- self._gmp: Optional[SUPPORTED_GMP_VERSIONS] = None
70
+ self._gmp: SUPPORTED_GMP_VERSIONS | None = None
71
71
 
72
72
  def determine_remote_gmp_version(self) -> str:
73
73
  """Determine the supported GMP version of the remote daemon"""
@@ -131,9 +131,9 @@ class GMP(GvmProtocol[T]):
131
131
 
132
132
  def __exit__(
133
133
  self,
134
- exc_type: Optional[Type[BaseException]],
135
- exc_value: Optional[BaseException],
136
- traceback: Optional[TracebackType],
134
+ exc_type: type[BaseException] | None,
135
+ exc_value: BaseException | None,
136
+ traceback: TracebackType | None,
137
137
  ) -> None:
138
138
  if self._gmp:
139
139
  self._gmp.disconnect()