Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 43 additions & 25 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout source
uses: actions/checkout@v4.2.2
uses: actions/checkout@v6.0.2
- name: Set up Python 3.14 for linting
uses: actions/setup-python@v5.6.0
with:
Expand All @@ -34,12 +34,14 @@ jobs:
run: |-
# stop the build if there are Python syntax errors or undefined names
flake8 ./src/xdoctest --count --select=E9,F63,F7,F82 --show-source --statistics
- name: Typecheck with mypy
- name: Typecheck
run: |-
python -m pip install mypy
pip install -r requirements/runtime.txt
mypy --install-types --non-interactive ./src/xdoctest
mypy ./src/xdoctest
python -m pip install ty
pip install -r requirements/runtime.txt
ty check ./src/xdoctest
build_and_test_sdist:
##
# Build the pure python package from source and test it in the
Expand All @@ -49,16 +51,16 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout source
uses: actions/checkout@v4.2.2
uses: actions/checkout@v6.0.2
- name: Set up Python 3.14
uses: actions/setup-python@v5.6.0
with:
python-version: '3.14'
- name: Upgrade pip
run: |-
python -m pip install pip uv -U
python -m uv pip install -r requirements/tests.txt
python -m uv pip install -r requirements/runtime.txt
python -m pip install --prefer-binary -r requirements/tests.txt
python -m pip install --prefer-binary -r requirements/runtime.txt
- name: Build sdist
shell: bash
run: |-
Expand All @@ -69,7 +71,7 @@ jobs:
- name: Install sdist
run: |-
ls -al wheelhouse
python -m uv pip install wheelhouse/xdoctest*.tar.gz -v
python -m pip install --prefer-binary wheelhouse/xdoctest*.tar.gz -v
- name: Test minimal loose sdist
env: {}
run: |-
Expand Down Expand Up @@ -101,7 +103,7 @@ jobs:
echo "MOD_DPATH = $MOD_DPATH"
python -m pytest --verbose --cov=xdoctest $MOD_DPATH ../tests
cd ..
- uses: actions/upload-artifact@v4.4.0
- uses: actions/upload-artifact@v6.0.0
name: Upload sdist artifact
with:
name: sdist_wheels
Expand All @@ -124,9 +126,9 @@ jobs:
- auto
steps:
- name: Checkout source
uses: actions/checkout@v4.2.2
uses: actions/checkout@v6.0.2
- name: Set up QEMU
uses: docker/setup-qemu-action@v3.0.0
uses: docker/setup-qemu-action@v3.7.0
if: runner.os == 'Linux' && matrix.arch != 'auto'
with:
platforms: all
Expand All @@ -144,7 +146,7 @@ jobs:
- name: Show built files
shell: bash
run: ls -la wheelhouse
- uses: actions/upload-artifact@v4.4.0
- uses: actions/upload-artifact@v6.0.0
name: Upload wheels artifact
with:
name: wheels-${{ matrix.os }}-${{ matrix.arch }}
Expand Down Expand Up @@ -291,14 +293,14 @@ jobs:
arch: auto
steps:
- name: Checkout source
uses: actions/checkout@v4.2.2
uses: actions/checkout@v6.0.2
- name: Enable MSVC 64bit
uses: ilammy/msvc-dev-cmd@v1
if: ${{ startsWith(matrix.os, 'windows-') }}
with:
arch: ${{ contains(matrix.os, 'arm') && 'arm64' || 'x64' }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3.0.0
uses: docker/setup-qemu-action@v3.7.0
if: runner.os == 'Linux' && matrix.arch != 'auto'
with:
platforms: all
Expand Down Expand Up @@ -327,13 +329,29 @@ jobs:
echo "Installing helpers: setuptools"
python -m uv pip install setuptools>=0.8 setuptools_scm wheel build -U
echo "Installing helpers: tomli and pkginfo"
python -m uv pip install tomli pkginfo
python -m uv pip install tomli pkginfo packaging
export WHEEL_FPATH=$(python -c "if 1:
import pathlib
from packaging import tags
from packaging.utils import parse_wheel_filename
dist_dpath = pathlib.Path('wheelhouse')
candidates = list(dist_dpath.glob('xdoctest*.whl'))
candidates += list(dist_dpath.glob('xdoctest*.tar.gz'))
fpath = sorted(candidates)[-1]
wheels = sorted(dist_dpath.glob('xdoctest*.whl'))
if wheels:
sys_tags = set(tags.sys_tags())
matching = []
for w in wheels:
try:
_, _, _, wheel_tags = parse_wheel_filename(w.name)
except Exception:
continue
if any(t in sys_tags for t in wheel_tags):
matching.append(w)
fpath = sorted(matching or wheels)[-1]
else:
sdists = sorted(dist_dpath.glob('xdoctest*.tar.gz'))
if not sdists:
raise SystemExit('No wheel artifacts found in wheelhouse')
fpath = sdists[-1]
print(str(fpath).replace(chr(92), chr(47)))
")
export MOD_VERSION=$(python -c "if 1:
Expand All @@ -348,7 +366,7 @@ jobs:
echo "INSTALL_EXTRAS=$INSTALL_EXTRAS"
echo "UV_RESOLUTION=$UV_RESOLUTION"
echo "MOD_VERSION=$MOD_VERSION"
python -m uv pip install "xdoctest[$INSTALL_EXTRAS]==$MOD_VERSION" -f wheelhouse
python -m pip install --prefer-binary "xdoctest[$INSTALL_EXTRAS]==$MOD_VERSION" -f wheelhouse
echo "Install finished."
- name: Test wheel ${{ matrix.install-extras }}
shell: bash
Expand Down Expand Up @@ -396,7 +414,7 @@ jobs:
echo '### The cwd should now have a coverage.xml'
ls -altr
pwd
- uses: codecov/codecov-action@v5.4.3
- uses: codecov/codecov-action@v5.5.2
name: Codecov Upload
with:
file: ./coverage.xml
Expand All @@ -410,7 +428,7 @@ jobs:
- build_purepy_wheels
steps:
- name: Checkout source
uses: actions/checkout@v4.2.2
uses: actions/checkout@v6.0.2
- uses: actions/download-artifact@v4.1.8
name: Download wheels
with:
Expand Down Expand Up @@ -467,7 +485,7 @@ jobs:
ots stamp wheelhouse/*.whl wheelhouse/*.tar.gz wheelhouse/*.asc
ls -la wheelhouse
twine upload --username __token__ --password "$TWINE_PASSWORD" --repository-url "$TWINE_REPOSITORY_URL" wheelhouse/*.whl wheelhouse/*.tar.gz --skip-existing --verbose || { echo "failed to twine upload" ; exit 1; }
- uses: actions/upload-artifact@v4.4.0
- uses: actions/upload-artifact@v6.0.0
name: Upload deploy artifacts
with:
name: deploy_artifacts
Expand All @@ -486,7 +504,7 @@ jobs:
- build_purepy_wheels
steps:
- name: Checkout source
uses: actions/checkout@v4.2.2
uses: actions/checkout@v6.0.2
- uses: actions/download-artifact@v4.1.8
name: Download wheels
with:
Expand Down Expand Up @@ -543,7 +561,7 @@ jobs:
ots stamp wheelhouse/*.whl wheelhouse/*.tar.gz wheelhouse/*.asc
ls -la wheelhouse
twine upload --username __token__ --password "$TWINE_PASSWORD" --repository-url "$TWINE_REPOSITORY_URL" wheelhouse/*.whl wheelhouse/*.tar.gz --skip-existing --verbose || { echo "failed to twine upload" ; exit 1; }
- uses: actions/upload-artifact@v4.4.0
- uses: actions/upload-artifact@v6.0.0
name: Upload deploy artifacts
with:
name: deploy_artifacts
Expand All @@ -563,7 +581,7 @@ jobs:
- live_deploy
steps:
- name: Checkout source
uses: actions/checkout@v4.2.2
uses: actions/checkout@v6.0.2
- uses: actions/download-artifact@v4.1.8
name: Download artifacts
with:
Expand Down Expand Up @@ -617,4 +635,4 @@ jobs:
# --secret=EROTEMIC_TWINE_USERNAME=$EROTEMIC_TWINE_USERNAME \
# --secret=EROTEMIC_CI_SECRET=$EROTEMIC_CI_SECRET \
# --secret=EROTEMIC_TEST_TWINE_USERNAME=$EROTEMIC_TEST_TWINE_USERNAME \
# --secret=EROTEMIC_TEST_TWINE_PASSWORD=$EROTEMIC_TEST_TWINE_PASSWORD
# --secret=EROTEMIC_TEST_TWINE_PASSWORD=$EROTEMIC_TEST_TWINE_PASSWORD
15 changes: 15 additions & 0 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,30 @@

# Required
version: 2

build:
os: "ubuntu-24.04"
tools:
python: "3.13"

# Build documentation in the docs/ directory with Sphinx
sphinx:
configuration: docs/source/conf.py

# Build documentation with MkDocs
#mkdocs:
# configuration: mkdocs.yml

# Optionally build your docs in additional formats such as PDF and ePub
formats: all

python:
install:
- requirements: requirements/docs.txt
- method: pip
path: .
#extra_requirements:
# - docs

#conda:
# environment: environment.yml
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def visit_Assign(self, node):


project = 'xdoctest'
copyright = '2025, Jon Crall'
copyright = '2026, Jon Crall'
author = 'Jon Crall'
modname = 'xdoctest'

Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ requires = [ "setuptools>=41.0.1",]
build-backend = "setuptools.build_meta"

[tool.xcookie]
tags = [ "erotemic", "github", "purepy",]
tags = [ "erotemic", "github", "purepy", "mypy"]
mod_name = "xdoctest"
repo_name = "xdoctest"
rel_mod_parent_dpath = "./src"
Expand Down Expand Up @@ -96,6 +96,7 @@ ignore_missing_imports = true

[tool.ty.rules]
unused-type-ignore-comment = "ignore"
unresolved-import = "ignore"

[[tool.ty.overrides]]
include = ["src/xdoctest/_tokenize.py"]
Expand Down
13 changes: 6 additions & 7 deletions src/xdoctest/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,17 +321,16 @@ def fib(n):
]


from xdoctest import utils
from xdoctest import docstr
from xdoctest.runner import (
doctest_module,
doctest_callable,
)
from xdoctest import docstr, utils
from xdoctest.exceptions import (
DoctestParseError,
ExistingEventLoopError,
ExitTestException,
MalformedDocstr,
ExistingEventLoopError,
)
from xdoctest.runner import (
doctest_callable,
doctest_module,
)

__all__ = [
Expand Down
8 changes: 3 additions & 5 deletions src/xdoctest/checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,11 @@

from __future__ import annotations

import difflib
import re
import typing

import re
import difflib
from xdoctest import utils
from xdoctest import constants
from xdoctest import directive
from xdoctest import constants, directive, utils

unicode_literal_re = re.compile(r'(\W|^)[uU]([rR]?[\'\"])', re.UNICODE)
bytes_literal_re = re.compile(r'(\W|^)[bB]([rR]?[\'\"])', re.UNICODE)
Expand Down
3 changes: 2 additions & 1 deletion src/xdoctest/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ def __bool__(self) -> bool:

__nonzero__ = __bool__


NOT_EVALED: _NOT_EVAL_TYPE

if 'NOT_EVALED' not in globals():
NOT_EVALED = object.__new__(_NOT_EVAL_TYPE)
NOT_EVALED = object.__new__(_NOT_EVAL_TYPE)
34 changes: 18 additions & 16 deletions src/xdoctest/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,25 +22,26 @@

from __future__ import annotations

import typing

import textwrap
import warnings
import itertools as it
import types
import os
from os.path import exists
import textwrap
import types
import typing
import warnings
from fnmatch import fnmatch
from xdoctest import dynamic_analysis
from xdoctest import static_analysis
from xdoctest import parser
from xdoctest import exceptions
from xdoctest import doctest_example
from xdoctest import utils
from os.path import exists

from xdoctest import (
doctest_example,
dynamic_analysis,
exceptions,
global_state,
parser,
static_analysis,
utils,
)
from xdoctest.docstr import docscrape_google
from xdoctest.utils import util_import
from xdoctest import global_state


DOCTEST_STYLES = [
'freeform',
Expand Down Expand Up @@ -552,7 +553,8 @@ def package_calldefs(
else:
pkgpath = _rectify_to_modpath(pkg_identifier)
_ideniter = static_analysis.package_modpaths(
pkgpath, with_pkg=True, with_libs=True)
pkgpath, with_pkg=True, with_libs=True
)
identifiers = list(_ideniter)

for module_identifier in identifiers:
Expand Down Expand Up @@ -654,7 +656,7 @@ def parse_calldefs(
calldefs = static_analysis.parse_static_calldefs(
fpath=module_identifier
)

assert calldefs is not None
if global_state.DEBUG_CORE: # nocover
print(f'Found {len(calldefs)} calldefs')
Expand Down
Loading
Loading