Skip to content

Commit 37a488a

Browse files
c0llab0rat0rntninja
authored andcommitted
Modernize typing in exceptions.py
1 parent e656e08 commit 37a488a

File tree

1 file changed

+22
-17
lines changed

1 file changed

+22
-17
lines changed

ipfshttpclient/exceptions.py

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -34,25 +34,27 @@ class AddressError(Error, multiaddr.exceptions.Error): # type: ignore[no-any-un
3434
"""Raised when the provided daemon location Multiaddr does not match any
3535
of the supported patterns."""
3636
__slots__ = ("addr",)
37-
#addr: ty.Union[str, bytes]
37+
38+
addr: ty.Union[str, bytes]
3839

3940
def __init__(self, addr: ty.Union[str, bytes]) -> None:
40-
self.addr = addr # type: ty.Union[str, bytes]
41+
self.addr = addr
4142
Error.__init__(self, "Unsupported Multiaddr pattern: {0!r}".format(addr))
4243

4344

4445
class VersionMismatch(Warning):
4546
"""Raised when daemon version is not supported by this client version."""
4647
__slots__ = ("current", "minimum", "maximum")
47-
#current: ty.Sequence[int]
48-
#minimum: ty.Sequence[int]
49-
#maximum: ty.Sequence[int]
48+
49+
current: ty.Sequence[int]
50+
minimum: ty.Sequence[int]
51+
maximum: ty.Sequence[int]
5052

5153
def __init__(self, current: ty.Sequence[int], minimum: ty.Sequence[int],
5254
maximum: ty.Sequence[int]) -> None:
53-
self.current = current # type: ty.Sequence[int]
54-
self.minimum = minimum # type: ty.Sequence[int]
55-
self.maximum = maximum # type: ty.Sequence[int]
55+
self.current = current
56+
self.minimum = minimum
57+
self.maximum = maximum
5658

5759
msg = "Unsupported daemon version '{}' (not in range: {} ≤ … < {})".format(
5860
".".join(map(str, current)), ".".join(map(str, minimum)), ".".join(map(str, maximum))
@@ -66,10 +68,11 @@ def __init__(self, current: ty.Sequence[int], minimum: ty.Sequence[int],
6668
class EncoderError(Error):
6769
"""Base class for all encoding and decoding related errors."""
6870
__slots__ = ("encoder_name",)
69-
#encoder_name: str
71+
72+
encoder_name: str
7073

7174
def __init__(self, message: str, encoder_name: str) -> None:
72-
self.encoder_name = encoder_name # type: str
75+
self.encoder_name = encoder_name
7376

7477
super().__init__(message)
7578

@@ -86,10 +89,11 @@ class EncodingError(EncoderError):
8689
"""Raised when encoding a Python object into a byte string has failed
8790
due to some problem with the input data."""
8891
__slots__ = ("original",)
89-
#original: Exception
92+
93+
original: Exception
9094

9195
def __init__(self, encoder_name: str, original: Exception) -> None:
92-
self.original = original # type: Exception
96+
self.original = original
9397

9498
super().__init__("Object encoding error: {}".format(original), encoder_name)
9599

@@ -98,10 +102,11 @@ class DecodingError(EncoderError):
98102
"""Raised when decoding a byte string to a Python object has failed due to
99103
some problem with the input data."""
100104
__slots__ = ("original",)
101-
#original: Exception
105+
106+
original: Exception
102107

103108
def __init__(self, encoder_name: str, original: Exception) -> None:
104-
self.original = original # type: Exception
109+
self.original = original
105110

106111
super().__init__("Object decoding error: {}".format(original), encoder_name)
107112

@@ -128,13 +133,13 @@ def __init__(self, matcher_class: type, invalid_spec: ty.Any) -> None:
128133
class CommunicationError(Error):
129134
"""Base class for all network communication related errors."""
130135
__slots__ = ("original",)
131-
#original: ty.Optional[Exception]
136+
137+
original: ty.Optional[Exception]
132138

133139
def __init__(self, original: ty.Optional[Exception],
134140
_message: ty.Optional[str] = None) -> None:
135-
self.original = original # type: ty.Optional[Exception]
141+
self.original = original
136142

137-
msg = "" # type: str
138143
if _message:
139144
msg = _message
140145
else:

0 commit comments

Comments
 (0)