Skip to content

Commit

Permalink
chore: Skip type-checking on Python 3.7
Browse files Browse the repository at this point in the history
  • Loading branch information
pawamoy committed Feb 10, 2023
1 parent 9153522 commit 408c471
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions duties.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import importlib
import os
import sys
from functools import wraps
from io import StringIO
from pathlib import Path

Expand All @@ -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.
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 408c471

Please sign in to comment.