Skip to content

Commit 64ea98d

Browse files
authored
Merge pull request #54 from adafruit/patch-fix
Linted
2 parents da37fe3 + e32917a commit 64ea98d

File tree

4 files changed

+19
-20
lines changed

4 files changed

+19
-20
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ repos:
2424
name: pylint (library code)
2525
types: [python]
2626
args:
27-
- --disable=consider-using-f-string
27+
- --disable=consider-using-f-string,duplicate-code
2828
exclude: "^(docs/|examples/|tests/|setup.py$)"
2929
- id: pylint
3030
name: pylint (example code)

adafruit_portalbase/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ def _fill_text_labels(self, values):
391391
# fill out all the text blocks
392392
if self._text:
393393
value_index = 0 # In case values and text is not the same
394-
for i in range(len(self._text)):
394+
for i in range(len(self._text)): # pylint: disable=consider-using-enumerate
395395
if (not self._text[i]["is_data"]) or (value_index > (len(values) - 1)):
396396
continue
397397
string = None

adafruit_portalbase/graphics.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@ def set_background(self, file_or_color, position=None):
8181
if self._bg_file:
8282
self._bg_file.close()
8383
if isinstance(file_or_color, str): # its a filenme:
84-
self._bg_file = open(file_or_color, "rb")
85-
background = displayio.OnDiskBitmap(self._bg_file)
84+
with open(file_or_color, "rb") as self._bg_file:
85+
background = displayio.OnDiskBitmap(self._bg_file)
8686
self._bg_sprite = displayio.TileGrid(
8787
background,
8888
pixel_shader=getattr(

adafruit_portalbase/network.py

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -290,22 +290,21 @@ def wget(self, url, filename, *, chunk_size=12000):
290290
remaining = content_length
291291
print("Saving data to ", filename)
292292
stamp = time.monotonic()
293-
file = open(filename, "wb")
294-
for i in response.iter_content(min(remaining, chunk_size)): # huge chunks!
295-
self.neo_status(STATUS_DOWNLOADING)
296-
remaining -= len(i)
297-
file.write(i)
298-
if self._debug:
299-
print(
300-
"Read %d bytes, %d remaining"
301-
% (content_length - remaining, remaining)
302-
)
303-
else:
304-
print(".", end="")
305-
if not remaining:
306-
break
307-
self.neo_status(STATUS_FETCHING)
308-
file.close()
293+
with open(filename, "wb") as file:
294+
for i in response.iter_content(min(remaining, chunk_size)): # huge chunks!
295+
self.neo_status(STATUS_DOWNLOADING)
296+
remaining -= len(i)
297+
file.write(i)
298+
if self._debug:
299+
print(
300+
"Read %d bytes, %d remaining"
301+
% (content_length - remaining, remaining)
302+
)
303+
else:
304+
print(".", end="")
305+
if not remaining:
306+
break
307+
self.neo_status(STATUS_FETCHING)
309308

310309
response.close()
311310
stamp = time.monotonic() - stamp

0 commit comments

Comments
 (0)