Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions src/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ def __init__(
out: typing.Optional[T_OUT_DATA] = None,
error: typing.Optional[T_ERR_DATA] = None,
):
assert message is None or type(message) == str # noqa: E721
assert command is None or type(command) in [str, list] # noqa: E721
assert exit_code is None or type(exit_code) == int # noqa: E721
assert out is None or type(out) in [str, bytes] # noqa: E721
assert error is None or type(error) in [str, bytes] # noqa: E721
assert message is None or type(message) is str
assert command is None or type(command) in [str, list]
assert exit_code is None or type(exit_code) is int
assert out is None or type(out) in [str, bytes]
assert error is None or type(error) in [str, bytes]

super().__init__(message)

Expand Down Expand Up @@ -61,32 +61,32 @@ def message(self) -> str:
msg.append(u'---- Out:\n{}'.format(self.out))

r = self.convert_and_join(msg)
assert type(r) == str # noqa: E721
assert type(r) is str
return r

@property
def description(self) -> typing.Optional[str]:
assert self._description is None or type(self._description) == str # noqa: E721
assert self._description is None or type(self._description) is str
return self._description

@property
def command(self) -> typing.Optional[T_CMD]:
assert self._command is None or type(self._command) in [str, list] # noqa: E721
assert self._command is None or type(self._command) in [str, list]
return self._command

@property
def exit_code(self) -> typing.Optional[int]:
assert self._exit_code is None or type(self._exit_code) == int # noqa: E721
assert self._exit_code is None or type(self._exit_code) is int
return self._exit_code

@property
def out(self) -> typing.Optional[T_OUT_DATA]:
assert self._out is None or type(self._out) in [str, bytes] # noqa: E721
assert self._out is None or type(self._out) in [str, bytes]
return self._out

@property
def error(self) -> typing.Optional[T_ERR_DATA]:
assert self._error is None or type(self._error) in [str, bytes] # noqa: E721
assert self._error is None or type(self._error) in [str, bytes]
return self._error

def __repr__(self) -> str:
Expand Down
8 changes: 4 additions & 4 deletions src/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def GetDefaultEncoding():

if r:
assert r is not None
assert type(r) == str # noqa: E721
assert type(r) is str
assert r != ""
return r

Expand All @@ -43,13 +43,13 @@ def PrepareProcessInput(input, encoding):
if not input:
return None

if type(input) == str: # noqa: E721
if type(input) is str:
if encoding is None:
return input.encode(__class__.GetDefaultEncoding())

assert type(encoding) == str # noqa: E721
assert type(encoding) is str
return input.encode(encoding)

# It is expected!
assert type(input) == bytes # noqa: E721
assert type(input) is bytes
return input
Loading