|
14 | 14 |
|
15 | 15 |
|
16 | 16 | def _code_format(session: Session, mode: Mode, files: Iterable[str]) -> None: |
17 | | - isort = ["poetry", "run", "isort", "-v"] |
18 | | - black = ["poetry", "run", "black"] |
19 | | - isort = isort if mode == Mode.Fix else isort + ["--check"] |
20 | | - black = black if mode == Mode.Fix else black + ["--check"] |
21 | | - session.run(*isort, *files) |
22 | | - session.run(*black, *files) |
| 17 | + def command(*args: str) -> list[str]: |
| 18 | + return args if mode==Mode.Fix else list(args) + ["--check"] |
| 19 | + |
| 20 | + session.run(*command("poetry", "run", "isort"), *files) |
| 21 | + session.run(*command("poetry", "run", "black"), *files) |
23 | 22 |
|
24 | 23 |
|
25 | 24 | def _pyupgrade(session: Session, files: Iterable[str]) -> None: |
@@ -47,3 +46,13 @@ def fmt_check(session: Session) -> None: |
47 | 46 | """Checks the project for correct formatting""" |
48 | 47 | py_files = [f"{file}" for file in python_files(PROJECT_CONFIG.root)] |
49 | 48 | _code_format(session=session, mode=Mode.Check, files=py_files) |
| 49 | + |
| 50 | + |
| 51 | +class XSession: |
| 52 | + def run(self, *args): |
| 53 | + print(f'session.run(args: {args})') |
| 54 | + |
| 55 | + |
| 56 | +if __name__ == "__main__": |
| 57 | + session = XSession() |
| 58 | + _code_format(session, Mode.Fix, []) |
0 commit comments