55import os
66import re
77import sys
8- from contextlib import contextmanager
9- from importlib .metadata import version as pkgversion
108from pathlib import Path
119from typing import TYPE_CHECKING
1210
1311from duty import duty , tools
1412
1513if TYPE_CHECKING :
16- from collections .abc import Iterator
17-
1814 from duty .context import Context
1915
2016
2521WINDOWS = os .name == "nt"
2622PTY = not WINDOWS and not CI
2723MULTIRUN = os .environ .get ("MULTIRUN" , "0" ) == "1"
24+ PY_VERSION = f"{ sys .version_info .major } { sys .version_info .minor } "
25+ PY_DEV = "314"
2826
2927
3028def pyprefix (title : str ) -> str :
@@ -34,18 +32,6 @@ def pyprefix(title: str) -> str:
3432 return title
3533
3634
37- @contextmanager
38- def material_insiders () -> Iterator [bool ]:
39- if "+insiders" in pkgversion ("mkdocs-material" ):
40- os .environ ["MATERIAL_INSIDERS" ] = "true"
41- try :
42- yield True
43- finally :
44- os .environ .pop ("MATERIAL_INSIDERS" )
45- else :
46- yield False
47-
48-
4935def _get_changelog_version () -> str :
5036 changelog_version_re = re .compile (r"^## \[(\d+\.\d+\.\d+)\].*$" )
5137 with Path (__file__ ).parent .joinpath ("CHANGELOG.md" ).open ("r" , encoding = "utf8" ) as file :
@@ -68,7 +54,7 @@ def check(ctx: Context) -> None:
6854 """Check it all!"""
6955
7056
71- @duty
57+ @duty ( nofail = PY_VERSION == PY_DEV )
7258def check_quality (ctx : Context ) -> None :
7359 """Check the code quality."""
7460 ctx .run (
@@ -77,19 +63,18 @@ def check_quality(ctx: Context) -> None:
7763 )
7864
7965
80- @duty
66+ @duty ( nofail = PY_VERSION == PY_DEV )
8167def check_docs (ctx : Context ) -> None :
8268 """Check if the documentation builds correctly."""
8369 Path ("htmlcov" ).mkdir (parents = True , exist_ok = True )
8470 Path ("htmlcov/index.html" ).touch (exist_ok = True )
85- with material_insiders ():
86- ctx .run (
87- tools .mkdocs .build (strict = True , verbose = True ),
88- title = pyprefix ("Building documentation" ),
89- )
71+ ctx .run (
72+ tools .mkdocs .build (strict = True , verbose = True ),
73+ title = pyprefix ("Building documentation" ),
74+ )
9075
9176
92- @duty
77+ @duty ( nofail = PY_VERSION == PY_DEV )
9378def check_types (ctx : Context ) -> None :
9479 """Check that the code is correctly typed."""
9580 os .environ ["MYPYPATH" ] = "src"
@@ -100,7 +85,7 @@ def check_types(ctx: Context) -> None:
10085 )
10186
10287
103- @duty
88+ @duty ( nofail = PY_VERSION == PY_DEV )
10489def check_api (ctx : Context , * cli_args : str ) -> None :
10590 """Check for API breaking changes."""
10691 ctx .run (
@@ -118,22 +103,18 @@ def docs(ctx: Context, *cli_args: str, host: str = "127.0.0.1", port: int = 8000
118103 host: The host to serve the docs from.
119104 port: The port to serve the docs on.
120105 """
121- with material_insiders ():
122- ctx .run (
123- tools .mkdocs .serve (dev_addr = f"{ host } :{ port } " ).add_args (* cli_args ),
124- title = "Serving documentation" ,
125- capture = False ,
126- )
106+ ctx .run (
107+ tools .mkdocs .serve (dev_addr = f"{ host } :{ port } " ).add_args (* cli_args ),
108+ title = "Serving documentation" ,
109+ capture = False ,
110+ )
127111
128112
129113@duty
130114def docs_deploy (ctx : Context ) -> None :
131115 """Deploy the documentation to GitHub pages."""
132116 os .environ ["DEPLOY" ] = "true"
133- with material_insiders () as insiders :
134- if not insiders :
135- ctx .run (lambda : False , title = "Not deploying docs without Material for MkDocs Insiders!" )
136- ctx .run (tools .mkdocs .gh_deploy (), title = "Deploying documentation" )
117+ ctx .run (tools .mkdocs .gh_deploy (force = True ), title = "Deploying documentation" )
137118
138119
139120@duty
@@ -180,7 +161,7 @@ def release(ctx: Context, version: str = "") -> None:
180161 ctx .run ("false" , title = "A version must be provided" )
181162 ctx .run ("git add pyproject.toml CHANGELOG.md" , title = "Staging files" , pty = PTY )
182163 ctx .run (["git" , "commit" , "-m" , f"chore: Prepare release { version } " ], title = "Committing changes" , pty = PTY )
183- ctx .run (f"git tag { version } " , title = "Tagging commit" , pty = PTY )
164+ ctx .run (f"git tag -m '' -a { version } " , title = "Tagging commit" , pty = PTY )
184165 ctx .run ("git push" , title = "Pushing commits" , pty = False )
185166 ctx .run ("git push --tags" , title = "Pushing tags" , pty = False )
186167
@@ -193,20 +174,15 @@ def coverage(ctx: Context) -> None:
193174 ctx .run (tools .coverage .html (rcfile = "config/coverage.ini" ))
194175
195176
196- @duty
197- def test (ctx : Context , * cli_args : str , match : str = "" ) -> None :
198- """Run the test suite.
199-
200- Parameters:
201- match: A pytest expression to filter selected tests.
202- """
203- py_version = f"{ sys .version_info .major } { sys .version_info .minor } "
204- os .environ ["COVERAGE_FILE" ] = f".coverage.{ py_version } "
177+ @duty (nofail = PY_VERSION == PY_DEV )
178+ def test (ctx : Context , * cli_args : str ) -> None :
179+ """Run the test suite."""
180+ os .environ ["COVERAGE_FILE" ] = f".coverage.{ PY_VERSION } "
181+ os .environ ["PYTHONWARNDEFAULTENCODING" ] = "1"
205182 ctx .run (
206183 tools .pytest (
207184 "tests" ,
208185 config_file = "config/pytest.ini" ,
209- select = match ,
210186 color = "yes" ,
211187 ).add_args ("-n" , "auto" , * cli_args ),
212188 title = pyprefix ("Running tests" ),
0 commit comments