Skip to content

Commit 8ad4a8e

Browse files
committed
remove pylint disables, format
1 parent bd91d4f commit 8ad4a8e

File tree

4 files changed

+12
-15
lines changed

4 files changed

+12
-15
lines changed

adafruit_binascii.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,12 @@
2222
https://github.com/adafruit/circuitpython/releases
2323
2424
"""
25+
2526
try:
27+
from binascii import hexlify, unhexlify
2628
from typing import Union
29+
2730
from circuitpython_typing import ReadableBuffer
28-
from binascii import hexlify, unhexlify
2931
except ImportError:
3032
pass
3133

@@ -59,12 +61,11 @@
5961
class Error(Exception):
6062
"""Exception raised on errors. These are usually programming errors."""
6163

62-
# pylint: disable=unnecessary-pass
6364
pass
6465

6566

6667
if not "unhexlify" in globals():
67-
# pylint: disable=function-redefined
68+
6869
def unhexlify(hexstr: Union[str, ReadableBuffer]) -> bytes:
6970
"""Return the binary data represented by hexstr.
7071
@@ -78,7 +79,7 @@ def unhexlify(hexstr: Union[str, ReadableBuffer]) -> bytes:
7879

7980

8081
if not "hexlify" in globals():
81-
# pylint: disable=function-redefined
82+
8283
def hexlify(data: ReadableBuffer) -> bytes:
8384
"""Return the hexadecimal representation of the
8485
binary data. Every byte of data is converted into
@@ -122,7 +123,7 @@ def a2b_base64(b64_data: ReadableBuffer) -> bytes:
122123
last_char_was_a_pad = False
123124

124125
for char in b64_data:
125-
char = chr(char)
126+
char = chr(char) # noqa: PLW2901
126127
if char == "=":
127128
if quad_pos > 2 or (quad_pos == 2 and last_char_was_a_pad):
128129
break # stop on 'xxx=' or on 'xx=='
@@ -137,12 +138,10 @@ def a2b_base64(b64_data: ReadableBuffer) -> bytes:
137138
quad_pos = (quad_pos + 1) & 3
138139
leftchar = (leftchar << 6) | n
139140
leftbits += 6
140-
#
141141
if leftbits >= 8:
142142
leftbits -= 8
143143
res.append((leftchar >> leftbits).to_bytes(1, "big"))
144144
leftchar &= (1 << leftbits) - 1
145-
#
146145
last_char_was_a_pad = False
147146
else:
148147
if leftbits != 0:
@@ -172,7 +171,6 @@ def b2a_base64(bin_data: ReadableBuffer) -> bytes:
172171
if leftbits >= 6:
173172
res.append(TABLE_B2A_B64[(leftchar >> (leftbits - 6)) & 0x3F])
174173
leftbits -= 6
175-
#
176174
if leftbits == 2:
177175
res.append(TABLE_B2A_B64[(leftchar & 3) << 4])
178176
res.append("=")

docs/api.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,8 @@
44
.. If your library file(s) are nested in a directory (e.g. /adafruit_foo/foo.py)
55
.. use this format as the module name: "adafruit_foo.foo"
66
7+
API Reference
8+
#############
9+
710
.. automodule:: adafruit_binascii
811
:members:

docs/conf.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
# -*- coding: utf-8 -*-
2-
31
# SPDX-FileCopyrightText: 2020 ladyada for Adafruit Industries
42
#
53
# SPDX-License-Identifier: MIT
64

5+
import datetime
76
import os
87
import sys
9-
import datetime
108

119
sys.path.insert(0, os.path.abspath(".."))
1210

@@ -48,9 +46,7 @@
4846
creation_year = "2019"
4947
current_year = str(datetime.datetime.now().year)
5048
year_duration = (
51-
current_year
52-
if current_year == creation_year
53-
else creation_year + " - " + current_year
49+
current_year if current_year == creation_year else creation_year + " - " + current_year
5450
)
5551
copyright = year_duration + " Brent Rubell "
5652
author = "Brent Rubell "

examples/binascii_simpletest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# SPDX-FileCopyrightText: 2020 ladyada for Adafruit Industries
22
# SPDX-License-Identifier: MIT
33

4-
from adafruit_binascii import hexlify, unhexlify, a2b_base64, b2a_base64
4+
from adafruit_binascii import a2b_base64, b2a_base64, hexlify, unhexlify
55

66
print("-- Binary<->Hex Conversions --")
77
# Binary data.

0 commit comments

Comments
 (0)