@@ -42,69 +42,65 @@ def coverage(ctx: Context, args: str = "", *, html: bool = False):
4242 report_cov (ctx , html = html )
4343
4444
45- @task (optional = ["args" ], help = {"args" : "black additional arguments" })
46- def lint_black (ctx : Context , args : str = "." ):
45+ def _lint (ctx : Context , args : str = "." ):
4746 args = args or "." # needed for hatch script
48- ctx .run ("black --version" , pty = use_pty )
49- ctx .run (f"black -- check --diff { args } " , pty = use_pty )
47+ ctx .run ("ruff --version" , pty = use_pty )
48+ ctx .run (f"ruff check { args } " , pty = use_pty )
5049
5150
5251@task (optional = ["args" ], help = {"args" : "ruff additional arguments" })
53- def lint_ruff (ctx : Context , args : str = "." ):
52+ def check_lint (ctx : Context , args : str = "." ):
53+ """check linting with ruff"""
5454 args = args or "." # needed for hatch script
55- ctx .run ("ruff --version" , pty = use_pty )
56- ctx .run (f"ruff check { args } " , pty = use_pty )
55+ _lint (ctx , args )
5756
5857
59- @task (
60- optional = ["args" ],
61- help = {
62- "args" : "linting tools (black, ruff) additional arguments, typically a path" ,
63- },
64- )
65- def lintall (ctx : Context , args : str = "." ):
66- """Check linting"""
58+ @task (optional = ["args" ], help = {"args" : "ruff additional arguments" })
59+ def fix_lint (ctx : Context , args : str = "." ):
60+ """fix linting issues with ruff"""
6761 args = args or "." # needed for hatch script
68- lint_black (ctx , args )
69- lint_ruff (ctx , args )
62+ _lint (ctx , f"--fix { args } " )
7063
7164
7265@task (optional = ["args" ], help = {"args" : "check tools (pyright) additional arguments" })
73- def check_pyright (ctx : Context , args : str = "" ):
66+ def check_type (ctx : Context , args : str = "" ):
7467 """check static types with pyright"""
7568 ctx .run ("pyright --version" )
7669 ctx .run (f"pyright { args } " , pty = use_pty )
7770
7871
79- @ task ( optional = [ "args" ], help = { " args" : "check tools (pyright) additional arguments" })
80- def checkall ( ctx : Context , args : str = "" ):
81- """check static types"""
82- check_pyright ( ctx , args )
72+ def _format ( ctx : Context , args : str = "." ):
73+ args = args or "." # needed for hatch script
74+ ctx . run ( "ruff --version" , pty = use_pty )
75+ ctx . run ( f"ruff format { args } " , pty = use_pty )
8376
8477
85- @task (optional = ["args" ], help = {"args" : "black additional arguments" })
86- def fix_black (ctx : Context , args : str = "." ):
87- """fix black formatting"""
78+ @task (optional = ["args" ], help = {"args" : "ruff additional arguments" })
79+ def check_format (ctx : Context , args : str = "." ):
80+ """check formatting with ruff """
8881 args = args or "." # needed for hatch script
89- ctx . run ( f"black { args } ", pty = use_pty )
82+ _format ( ctx , f"--check { args } " )
9083
9184
9285@task (optional = ["args" ], help = {"args" : "ruff additional arguments" })
93- def fix_ruff (ctx : Context , args : str = "." ):
94- """fix all ruff rules """
86+ def fix_format (ctx : Context , args : str = "." ):
87+ """fix formatting with ruff """
9588 args = args or "." # needed for hatch script
96- ctx . run ( f"ruff check --fix { args } " , pty = use_pty )
89+ _format ( ctx , args )
9790
9891
99- @task (
100- optional = ["args" ],
101- help = {
102- "args" : "linting tools (black, ruff) additional arguments, typically a path" ,
103- },
104- )
105- def fixall (ctx : Context , args : str = "." ):
92+ @task (optional = ["args" ], help = {"args" : "additional arguments" })
93+ def check_all (ctx : Context , args : str = "" ):
94+ """check linting, formatting and static types"""
95+ args = args or "." # needed for hatch script
96+ check_lint (ctx , args )
97+ check_format (ctx , args )
98+ check_type (ctx , args )
99+
100+
101+ @task (optional = ["args" ], help = {"args" : "additional arguments" })
102+ def fix_all (ctx : Context , args : str = "" ):
106103 """Fix everything automatically"""
107104 args = args or "." # needed for hatch script
108- fix_black (ctx , args )
109- fix_ruff (ctx , args )
110- lintall (ctx , args )
105+ fix_lint (ctx , args )
106+ fix_format (ctx , args )
0 commit comments