-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnoxfile.py
41 lines (33 loc) · 1.08 KB
/
noxfile.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import nox
nox.options.sessions = ("format", "lint")
files = (
"main.py",
"noxfile.py",
"src/__init__.py",
"src/characters.py",
"src/levels.py",
"src/menu.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")
session.run("ruff", "format", *files) # an important reinforcement to 'ruff check --fix'
@nox.session
def lint(session: nox.Session):
"Lint the codebase."
session.install("-r", "requirements.txt")
session.install("-r", "test-requirements.txt")
session.run("ruff", "check", *files)
@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", "saved_coins": 0}'
session.run(
"python",
"-c",
"import io; js = io.open('savedata.json', 'w'); " f"js.write('{new_data}'); " "js.close()",
)