Skip to content

Commit

Permalink
Minor changes to make pylint happy
Browse files Browse the repository at this point in the history
Closes #6
  • Loading branch information
sg495 committed Feb 3, 2023
1 parent ab80af3 commit 54f1423
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion dag_cbor/decoding/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ def _decode_bool_none(stream: Stream, arg: int, callback: Optional[DecodeCallbac
def _decode_dummy(stream: Stream, arg: int, callback: Optional[DecodeCallback]) -> Tuple[None, int]:
assert False, f"Major type {arg} does not have an associated decoder."

_decoders: tuple[Callable[[Stream, int, Optional[DecodeCallback]], tuple[EncodableType, int]], ...] = (
_decoders: Tuple[Callable[[Stream, int, Optional[DecodeCallback]], Tuple[EncodableType, int]], ...] = (
_decode_dummy,
_decode_dummy,
_decode_bytes,
Expand Down
7 changes: 4 additions & 3 deletions dag_cbor/decoding/_err.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"""

import math
from typing import Tuple
from typing_extensions import Literal

from multiformats import varint
Expand Down Expand Up @@ -130,10 +131,10 @@ def _invalid_tag(stream: Stream, arg: int) -> str:
hl_start = prev_snapshot.latest_read_size
return _decode_error_msg(msg, prev_snapshot, curr_snapshot, details=details, hl_start=hl_start)

def _cid(cid_head_snapshots: tuple[StreamSnapshot, StreamSnapshot], e: CBORDecodingError) -> str:
def _cid(cid_head_snapshots: Tuple[StreamSnapshot, StreamSnapshot], e: CBORDecodingError) -> str:
return _cid_error_template(cid_head_snapshots, *_extract_error_cause_lines(e))

def _cid_bytes(cid_head_snapshots: tuple[StreamSnapshot, StreamSnapshot], stream: Stream, cid_bytes: EncodableType) -> str:
def _cid_bytes(cid_head_snapshots: Tuple[StreamSnapshot, StreamSnapshot], stream: Stream, cid_bytes: EncodableType) -> str:
decoded_type = type(cid_bytes).__name__
decoded_type_details = f"decodes to an item of type {repr(decoded_type)}"
explanation = [
Expand All @@ -142,7 +143,7 @@ def _cid_bytes(cid_head_snapshots: tuple[StreamSnapshot, StreamSnapshot], stream
]
return _cid_error_template(cid_head_snapshots, *explanation)

def _cid_multibase(cid_head_snapshots: tuple[StreamSnapshot, StreamSnapshot], stream: Stream, cid_bytes: bytes) -> str:
def _cid_multibase(cid_head_snapshots: Tuple[StreamSnapshot, StreamSnapshot], stream: Stream, cid_bytes: bytes) -> str:
error_details = "byte should be 0x00"
explanation = [
"CID does not start with the identity Multibase prefix.",
Expand Down
4 changes: 2 additions & 2 deletions dag_cbor/decoding/_err_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Utility functions used to produce messages for DAG-CBOR decoding errors.
"""

from typing import List, Optional
from typing import List, Optional, Tuple

from ..utils import CBORDecodingError
from ._stream import StreamSnapshot
Expand Down Expand Up @@ -90,7 +90,7 @@ def _extract_error_cause_lines(e: CBORDecodingError) -> List[str]:
return [(r"\ " if idx == 0 else " ")+line for idx, line in enumerate(lines)]


def _cid_error_template(cid_head_snapshots: tuple[StreamSnapshot, StreamSnapshot], *explanation: str) -> str:
def _cid_error_template(cid_head_snapshots: Tuple[StreamSnapshot, StreamSnapshot], *explanation: str) -> str:
lines = [
"Error while decoding CID.",
*_decode_error_lines(*cid_head_snapshots, details="CID tag", dots=True),
Expand Down
4 changes: 2 additions & 2 deletions dag_cbor/random.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,9 @@ def options(*,
# pylint: disable = too-many-locals
global _options
global _rand
_old_options = _options
_old_rand = _rand
try:
_old_options = _options
_old_rand = _rand
set_options(seed=seed,
min_int=min_int, max_int=max_int,
min_bytes=min_bytes, max_bytes=max_bytes,
Expand Down

0 comments on commit 54f1423

Please sign in to comment.