From 408c4719eb17c993563375239a09bb8a83f16b2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Mazzucotelli?= Date: Fri, 10 Feb 2023 16:49:16 +0100 Subject: [PATCH] chore: Skip type-checking on Python 3.7 See https://github.com/python/mypy/issues/14670. --- duties.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/duties.py b/duties.py index 9726258..51bdc3c 100644 --- a/duties.py +++ b/duties.py @@ -3,6 +3,7 @@ import importlib import os import sys +from functools import wraps from io import StringIO from pathlib import Path @@ -25,6 +26,30 @@ def pyprefix(title: str) -> str: # noqa: D103 return title +def skip_if(condition: bool, reason: str): + """Decorator allowing to skip a duty if a condition is met. + + Parameters: + condition: The condition to meet. + reason: The reason to skip. + + Returns: + A decorator. + """ + + def decorator(func): + @wraps(func) + def wrapper(ctx, *args, **kwargs): + if condition: + ctx.run(["true"], title=reason) + else: + func(ctx, *args, **kwargs) + + return wrapper + + return decorator + + @duty def changelog(ctx): """Update the changelog in-place with latest commits. @@ -132,6 +157,13 @@ def check_docs(ctx): @duty # noqa: WPS231 +@skip_if( + sys.version_info < (3, 8), + reason=pyprefix( + "Checking types is not supported on Python 3.7 because of a mypy issue, " + "see https://github.com/python/mypy/issues/14670" + ), +) def check_types(ctx): # noqa: WPS231 """ Check that the code is correctly typed.