Skip to content

Commit

Permalink
Implement ruff format to our formatting system, and add some ruff r…
Browse files Browse the repository at this point in the history
…ules
  • Loading branch information
DiddiLeija committed Jul 12, 2024
1 parent bb1c090 commit 6094946
Show file tree
Hide file tree
Showing 8 changed files with 130 additions and 120 deletions.
9 changes: 5 additions & 4 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@ class Main:
Main object for the game, though most of the interface
is operated by the src-stored objects.
"""

situation = None

def __init__(self):
pyxel.load("resource.pyxres")
self.situation = init_class(stages_list["menu"], 0)
pyxel.run(self.update, self.draw)

def update(self):
self.situation.update()
# If the situation "ends", jump into the next one
Expand All @@ -29,16 +30,16 @@ def update(self):
if self.situation.nextlevel not in ("menu", "death"):
write_savedata({"level": self.situation.nextlevel})
self.situation = init_class(stages_list[self.situation.nextlevel], tmp)
del(tmp) # we have to remove 'tmp' ASAP
del tmp # we have to remove 'tmp' ASAP

def draw(self):
self.situation.draw()
draw_stats(
self.situation.get_scroll_x(),
self.situation.draw_v,
self.situation.player_choice,
self.situation.get_coin_count(),
str(type(self.situation))
str(type(self.situation)),
)


Expand Down
10 changes: 6 additions & 4 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,18 @@
"src/characters.py",
"src/levels.py",
"src/menu.py",
"src/tools.py"
"src/tools.py",
)


@nox.session
def format(session: nox.Session):
"Format the codebase."
session.install("-r", "requirements.txt")
session.install("-r", "test-requirements.txt")
session.run("ruff", "check", *files, "--fix") # TODO: ignore certain rules?
session.run("ruff", "format", *files) # a reinforcement to 'ruff check --fix'


@nox.session
def lint(session: nox.Session):
Expand All @@ -26,14 +29,13 @@ def lint(session: nox.Session):
session.install("-r", "test-requirements.txt")
session.run("ruff", "check", *files) # TODO: ignore certain rules?


@nox.session(name="reset-savedata")
def reset_savedata(session: nox.Session):
"Clean up 'savedata.json', which should not have any contents, use it carefully."
new_data = '{"level": "intro"}'
session.run(
"python",
"-c",
"import io; js = io.open('savedata.json', 'w'); "
f"js.write('{new_data}'); "
"js.close()"
"import io; js = io.open('savedata.json', 'w'); " f"js.write('{new_data}'); " "js.close()",
)
4 changes: 4 additions & 0 deletions ruff.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
line-length = 120

[lint]
extend-select = ["E501"]
2 changes: 1 addition & 1 deletion src/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from . import menu, levels, scenes

__all__ = ("stages_list")
__all__ = "stages_list"

# Below there's a dictionary with all the objects for further use
stages_list = {
Expand Down
Loading

0 comments on commit 6094946

Please sign in to comment.