1
1
# type: ignore
2
2
import shutil
3
- import subprocess
4
3
5
4
import toml
6
5
from invoke import Context , task
7
- from rich .console import Console
8
6
9
7
import monkey_patch_invoke as _ # noqa: F401
10
8
11
- console = Console ()
12
-
13
9
14
10
def get_pep8_compliant_name (project_name : str ) -> str :
15
11
return project_name .replace ('-' , '_' )
@@ -22,14 +18,6 @@ def get_project_path():
22
18
return project_name
23
19
24
20
25
- def execute_command (command : str ) -> dict [str , str ]:
26
- with subprocess .Popen (command , shell = True , stdout = subprocess .PIPE , stderr = subprocess .PIPE ) as process :
27
- stdout , stderr = process .communicate ()
28
- if process .returncode != 0 :
29
- raise Exception (stderr .decode ())
30
- return {'command' : command , 'result' : stdout .decode ()}
31
-
32
-
33
21
@task
34
22
def run (context : Context ):
35
23
context .run (f'python { get_project_path ()} /main.py' , pty = True )
@@ -41,23 +29,15 @@ def test(context: Context):
41
29
42
30
43
31
@task
44
- def format_code (context : Context , verbose : bool = False ) -> None :
32
+ def format_code (context : Context , verbose : bool = False ):
45
33
commands = [
46
34
f'pautoflake { get_project_path ()} ' ,
47
35
f'ruff --fix { get_project_path ()} ' ,
48
36
f'yapf --in-place --recursive --parallel { get_project_path ()} ' ,
49
37
]
50
- results : list [dict [str , str ]] = []
51
- with console .status ('[bold green] Formatting code...' ):
52
- for command in commands :
53
- results .append (execute_command (command ))
54
38
55
- if verbose :
56
- for result in results :
57
- console .print (f'$ { result ["command" ]} ' )
58
- console .print (result ['result' ])
59
-
60
- console .print ('[bold green]Success[/bold green]' )
39
+ for command in commands :
40
+ context .run (command , pty = True )
61
41
62
42
63
43
@task
@@ -69,7 +49,6 @@ def check(context: Context):
69
49
@task
70
50
def check_code_style (context : Context ):
71
51
commands = [
72
- f'pautoflake { get_project_path ()} --check' ,
73
52
f'ruff { get_project_path ()} ' ,
74
53
f'yapf --diff --recursive --parallel { get_project_path ()} ' ,
75
54
]
0 commit comments