8000 chore: Skip type-checking on Python 3.7 · pawamoy/duty@408c471 · GitHub
[go: up one dir, main page]

Skip to content

Commit 408c471

Browse files
committed
chore: Skip type-checking on Python 3.7
See python/mypy#14670.
1 parent 9153522 commit 408c471

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

duties.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import importlib
44
import os
55
import sys
6+
from functools import wraps
67
from io import StringIO
78
from pathlib import Path
89

@@ -25,6 +26,30 @@ def pyprefix(title: str) -> str: # noqa: D103
2526
return title
2627

2728

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+
2853
@duty
2954
def changelog(ctx):
3055
"""Update the changelog in-place with latest commits.
@@ -132,6 +157,13 @@ def check_docs(ctx):
132157

133158

134159
@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+
)
135167
def check_types(ctx): # noqa: WPS231
136168
"""
137169
Check that the code is correctly typed.

0 commit comments

Comments
 (0)
0