diff --git a/check.ps1 b/check.ps1 new file mode 100644 index 0000000..0e8adf1 --- /dev/null +++ b/check.ps1 @@ -0,0 +1,10 @@ +# +# Small script to ensure quality checks pass before submitting a commit/PR. +# +$ErrorActionPreference = "Stop" + +python -m ruff format docs src +python -m ruff check --fix --unsafe-fixes docs src + +# "--platform win32" to not fail on ctypes.windll (it does not affect the overall check on other OSes) +python -m mypy --platform win32 src docs/source/examples diff --git a/docs/source/conf.py b/docs/source/conf.py index 05471e5..76d00c6 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -8,6 +8,13 @@ import ctypes +# Monkey-patch PROT_READ into mmap if missing (Windows), so that we can +# import mss.linux.xshmgetimage while building the documentation. +import mmap + +if not hasattr(mmap, "PROT_READ"): + mmap.PROT_READ = 1 # type:ignore[attr-defined] + import mss # -- General configuration ------------------------------------------------ @@ -44,7 +51,6 @@ ctypes.WINFUNCTYPE = ctypes.CFUNCTYPE # type:ignore[attr-defined] ctypes.WinError = lambda _code=None, _descr=None: OSError() # type:ignore[attr-defined] - # -- Options for HTML output ---------------------------------------------- html_theme = "shibuya" diff --git a/docs/source/developers.rst b/docs/source/developers.rst index 160e0d6..24b394e 100644 --- a/docs/source/developers.rst +++ b/docs/source/developers.rst @@ -40,7 +40,8 @@ Code Quality To ensure the code quality is correct enough:: $ python -m pip install -e '.[dev]' - $ ./check.sh + $ ./check.sh # Linux/macOS + $ .\check.ps1 # Windows (PowerShell) Documentation