Skip to content

Commit

Permalink
ci: use the native libcst parser
Browse files Browse the repository at this point in the history
  • Loading branch information
onerandomusername committed Mar 1, 2023
1 parent 9ed0302 commit 64099fb
Showing 1 changed file with 25 additions and 3 deletions.
28 changes: 25 additions & 3 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,17 +95,32 @@ def slotscheck(session: nox.Session):
@nox.session(name="codemod")
def codemod(session: nox.Session):
"""Run libcst codemods."""
env = {"LIBCST_PARSER_TYPE": "native"}
session.run_always("pdm", "install", "-dG", "codemod", external=True)
if session.posargs and session.posargs[0] == "run-all" or not session.interactive:
# run all of the transformers on disnake
session.log("Running all transformers.")
res: str = session.run("python", "-m", "libcst.tool", "list", silent=True) # type: ignore
res: str = session.run(
"python",
"-m",
"libcst.tool",
"list",
silent=True,
env=env,
) # type: ignore
transformers = [line.split("-")[0].strip() for line in res.splitlines()]
session.log("Transformers: " + ", ".join(transformers))

for trans in transformers:
session.run(
"python", "-m", "libcst.tool", "codemod", trans, "disnake", "--hide-progress"
"python",
"-m",
"libcst.tool",
"codemod",
trans,
"disnake",
"--hide-progress",
env=env,
)
session.log("Finished running all transformers.")
else:
Expand All @@ -118,9 +133,16 @@ def codemod(session: nox.Session):
"libcst.tool",
"codemod",
*session.posargs,
env=env,
)
else:
session.run("python", "-m", "libcst.tool", "list")
session.run(
"python",
"-m",
"libcst.tool",
"list",
env=env,
)


@nox.session()
Expand Down

0 comments on commit 64099fb

Please sign in to comment.