File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change 3
3
import importlib
4
4
import os
5
5
import sys
6
+ from functools import wraps
6
7
from io import StringIO
7
8
from pathlib import Path
8
9
@@ -25,6 +26,30 @@ def pyprefix(title: str) -> str: # noqa: D103
25
26
return title
26
27
27
28
29
+ def skip_if (condition : bool , reason : str ):
30
+ """Decorator allowing to skip a duty if a condition is met.
31
+
32
+ Parameters:
33
+ condition: The condition to meet.
34
+ reason: The reason to skip.
35
+
36
+ Returns:
37
+ A decorator.
38
+ """
39
+
40
+ def decorator (func ):
41
+ @wraps (func )
42
+ def wrapper (ctx , * args , ** kwargs ):
43
+ if condition :
44
+ ctx .run (["true" ], title = reason )
45
+ else :
46
+ func (ctx , * args , ** kwargs )
47
+
48
+ return wrapper
49
+
50
+ return decorator
51
+
52
+
28
53
@duty
29
54
def changelog (ctx ):
30
55
"""Update the changelog in-place with latest commits.
@@ -132,6 +157,13 @@ def check_docs(ctx):
132
157
133
158
134
159
@duty # noqa: WPS231
160
+ @skip_if (
161
+ sys .version_info < (3 , 8 ),
162
+ reason = pyprefix (
163
+ "Checking types is not supported on Python 3.7 because of a mypy issue, "
164
+ "see https://github.com/python/mypy/issues/14670"
165
+ ),
166
+ )
135
167
def check_types (ctx ): # noqa: WPS231
136
168
"""
137
169
Check that the code is correctly typed.
You can’t perform that action at this time.
0 commit comments