Skip to content

Linted #27

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 5, 2021
Merged
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
15 changes: 9 additions & 6 deletions adafruit_pyoa.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,11 +173,12 @@ def load_game(self, game_directory):
)
self._gamefilename = game_directory + "/cyoa.json"
try:
game_file = open(self._gamefilename, "r")
with open( # pylint: disable=unspecified-encoding
self._gamefilename, "r"
) as game_file:
self._game = json.load(game_file)
except OSError as err:
raise OSError("Could not open game file " + self._gamefilename) from err
self._game = json.load(game_file)
game_file.close()

def _fade_to_black(self):
"""Turn down the lights."""
Expand Down Expand Up @@ -343,7 +344,7 @@ def play_sound(self, filename, *, wait_to_finish=True, loop=False):
except AttributeError:
self._display.wait_for_frame()
try:
self._wavfile = open(filename, "rb")
self._wavfile = open(filename, "rb") # pylint: disable=consider-using-with
except OSError as err:
raise OSError("Could not locate sound file", filename) from err

Expand Down Expand Up @@ -403,8 +404,10 @@ def set_background(self, filename, *, with_fade=True):
if filename:
if self._background_file:
self._background_file.close()
self._background_file = open(self._gamedirectory + "/" + filename, "rb")
background = displayio.OnDiskBitmap(self._background_file)
with open(
self._gamedirectory + "/" + filename, "rb"
) as self._background_file:
background = displayio.OnDiskBitmap(self._background_file)
self._background_sprite = displayio.TileGrid(
background,
pixel_shader=getattr(
Expand Down