Skip to content

Commit 8df2a92

Browse files
authored
xcookie and ruff updates
* Reformat code with ruff * Update xcookie * Ignore unresolved imports * wip
1 parent 97f8ae7 commit 8df2a92

24 files changed

+221
-175
lines changed

.github/workflows/tests.yml

Lines changed: 43 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
runs-on: ubuntu-latest
2222
steps:
2323
- name: Checkout source
24-
uses: actions/checkout@v4.2.2
24+
uses: actions/checkout@v6.0.2
2525
- name: Set up Python 3.14 for linting
2626
uses: actions/setup-python@v5.6.0
2727
with:
@@ -34,12 +34,14 @@ jobs:
3434
run: |-
3535
# stop the build if there are Python syntax errors or undefined names
3636
flake8 ./src/xdoctest --count --select=E9,F63,F7,F82 --show-source --statistics
37-
- name: Typecheck with mypy
37+
- name: Typecheck
3838
run: |-
3939
python -m pip install mypy
4040
pip install -r requirements/runtime.txt
41-
mypy --install-types --non-interactive ./src/xdoctest
4241
mypy ./src/xdoctest
42+
python -m pip install ty
43+
pip install -r requirements/runtime.txt
44+
ty check ./src/xdoctest
4345
build_and_test_sdist:
4446
##
4547
# Build the pure python package from source and test it in the
@@ -49,16 +51,16 @@ jobs:
4951
runs-on: ubuntu-latest
5052
steps:
5153
- name: Checkout source
52-
uses: actions/checkout@v4.2.2
54+
uses: actions/checkout@v6.0.2
5355
- name: Set up Python 3.14
5456
uses: actions/setup-python@v5.6.0
5557
with:
5658
python-version: '3.14'
5759
- name: Upgrade pip
5860
run: |-
5961
python -m pip install pip uv -U
60-
python -m uv pip install -r requirements/tests.txt
61-
python -m uv pip install -r requirements/runtime.txt
62+
python -m pip install --prefer-binary -r requirements/tests.txt
63+
python -m pip install --prefer-binary -r requirements/runtime.txt
6264
- name: Build sdist
6365
shell: bash
6466
run: |-
@@ -69,7 +71,7 @@ jobs:
6971
- name: Install sdist
7072
run: |-
7173
ls -al wheelhouse
72-
python -m uv pip install wheelhouse/xdoctest*.tar.gz -v
74+
python -m pip install --prefer-binary wheelhouse/xdoctest*.tar.gz -v
7375
- name: Test minimal loose sdist
7476
env: {}
7577
run: |-
@@ -101,7 +103,7 @@ jobs:
101103
echo "MOD_DPATH = $MOD_DPATH"
102104
python -m pytest --verbose --cov=xdoctest $MOD_DPATH ../tests
103105
cd ..
104-
- uses: actions/upload-artifact@v4.4.0
106+
- uses: actions/upload-artifact@v6.0.0
105107
name: Upload sdist artifact
106108
with:
107109
name: sdist_wheels
@@ -124,9 +126,9 @@ jobs:
124126
- auto
125127
steps:
126128
- name: Checkout source
127-
uses: actions/checkout@v4.2.2
129+
uses: actions/checkout@v6.0.2
128130
- name: Set up QEMU
129-
uses: docker/setup-qemu-action@v3.0.0
131+
uses: docker/setup-qemu-action@v3.7.0
130132
if: runner.os == 'Linux' && matrix.arch != 'auto'
131133
with:
132134
platforms: all
@@ -144,7 +146,7 @@ jobs:
144146
- name: Show built files
145147
shell: bash
146148
run: ls -la wheelhouse
147-
- uses: actions/upload-artifact@v4.4.0
149+
- uses: actions/upload-artifact@v6.0.0
148150
name: Upload wheels artifact
149151
with:
150152
name: wheels-${{ matrix.os }}-${{ matrix.arch }}
@@ -291,14 +293,14 @@ jobs:
291293
arch: auto
292294
steps:
293295
- name: Checkout source
294-
uses: actions/checkout@v4.2.2
296+
uses: actions/checkout@v6.0.2
295297
- name: Enable MSVC 64bit
296298
uses: ilammy/msvc-dev-cmd@v1
297299
if: ${{ startsWith(matrix.os, 'windows-') }}
298300
with:
299301
arch: ${{ contains(matrix.os, 'arm') && 'arm64' || 'x64' }}
300302
- name: Set up QEMU
301-
uses: docker/setup-qemu-action@v3.0.0
303+
uses: docker/setup-qemu-action@v3.7.0
302304
if: runner.os == 'Linux' && matrix.arch != 'auto'
303305
with:
304306
platforms: all
@@ -327,13 +329,29 @@ jobs:
327329
echo "Installing helpers: setuptools"
328330
python -m uv pip install setuptools>=0.8 setuptools_scm wheel build -U
329331
echo "Installing helpers: tomli and pkginfo"
330-
python -m uv pip install tomli pkginfo
332+
python -m uv pip install tomli pkginfo packaging
331333
export WHEEL_FPATH=$(python -c "if 1:
332334
import pathlib
335+
from packaging import tags
336+
from packaging.utils import parse_wheel_filename
333337
dist_dpath = pathlib.Path('wheelhouse')
334-
candidates = list(dist_dpath.glob('xdoctest*.whl'))
335-
candidates += list(dist_dpath.glob('xdoctest*.tar.gz'))
336-
fpath = sorted(candidates)[-1]
338+
wheels = sorted(dist_dpath.glob('xdoctest*.whl'))
339+
if wheels:
340+
sys_tags = set(tags.sys_tags())
341+
matching = []
342+
for w in wheels:
343+
try:
344+
_, _, _, wheel_tags = parse_wheel_filename(w.name)
345+
except Exception:
346+
continue
347+
if any(t in sys_tags for t in wheel_tags):
348+
matching.append(w)
349+
fpath = sorted(matching or wheels)[-1]
350+
else:
351+
sdists = sorted(dist_dpath.glob('xdoctest*.tar.gz'))
352+
if not sdists:
353+
raise SystemExit('No wheel artifacts found in wheelhouse')
354+
fpath = sdists[-1]
337355
print(str(fpath).replace(chr(92), chr(47)))
338356
")
339357
export MOD_VERSION=$(python -c "if 1:
@@ -348,7 +366,7 @@ jobs:
348366
echo "INSTALL_EXTRAS=$INSTALL_EXTRAS"
349367
echo "UV_RESOLUTION=$UV_RESOLUTION"
350368
echo "MOD_VERSION=$MOD_VERSION"
351-
python -m uv pip install "xdoctest[$INSTALL_EXTRAS]==$MOD_VERSION" -f wheelhouse
369+
python -m pip install --prefer-binary "xdoctest[$INSTALL_EXTRAS]==$MOD_VERSION" -f wheelhouse
352370
echo "Install finished."
353371
- name: Test wheel ${{ matrix.install-extras }}
354372
shell: bash
@@ -396,7 +414,7 @@ jobs:
396414
echo '### The cwd should now have a coverage.xml'
397415
ls -altr
398416
pwd
399-
- uses: codecov/codecov-action@v5.4.3
417+
- uses: codecov/codecov-action@v5.5.2
400418
name: Codecov Upload
401419
with:
402420
file: ./coverage.xml
@@ -410,7 +428,7 @@ jobs:
410428
- build_purepy_wheels
411429
steps:
412430
- name: Checkout source
413-
uses: actions/checkout@v4.2.2
431+
uses: actions/checkout@v6.0.2
414432
- uses: actions/download-artifact@v4.1.8
415433
name: Download wheels
416434
with:
@@ -467,7 +485,7 @@ jobs:
467485
ots stamp wheelhouse/*.whl wheelhouse/*.tar.gz wheelhouse/*.asc
468486
ls -la wheelhouse
469487
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; }
470-
- uses: actions/upload-artifact@v4.4.0
488+
- uses: actions/upload-artifact@v6.0.0
471489
name: Upload deploy artifacts
472490
with:
473491
name: deploy_artifacts
@@ -486,7 +504,7 @@ jobs:
486504
- build_purepy_wheels
487505
steps:
488506
- name: Checkout source
489-
uses: actions/checkout@v4.2.2
507+
uses: actions/checkout@v6.0.2
490508
- uses: actions/download-artifact@v4.1.8
491509
name: Download wheels
492510
with:
@@ -543,7 +561,7 @@ jobs:
543561
ots stamp wheelhouse/*.whl wheelhouse/*.tar.gz wheelhouse/*.asc
544562
ls -la wheelhouse
545563
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; }
546-
- uses: actions/upload-artifact@v4.4.0
564+
- uses: actions/upload-artifact@v6.0.0
547565
name: Upload deploy artifacts
548566
with:
549567
name: deploy_artifacts
@@ -563,7 +581,7 @@ jobs:
563581
- live_deploy
564582
steps:
565583
- name: Checkout source
566-
uses: actions/checkout@v4.2.2
584+
uses: actions/checkout@v6.0.2
567585
- uses: actions/download-artifact@v4.1.8
568586
name: Download artifacts
569587
with:
@@ -617,4 +635,4 @@ jobs:
617635
# --secret=EROTEMIC_TWINE_USERNAME=$EROTEMIC_TWINE_USERNAME \
618636
# --secret=EROTEMIC_CI_SECRET=$EROTEMIC_CI_SECRET \
619637
# --secret=EROTEMIC_TEST_TWINE_USERNAME=$EROTEMIC_TEST_TWINE_USERNAME \
620-
# --secret=EROTEMIC_TEST_TWINE_PASSWORD=$EROTEMIC_TEST_TWINE_PASSWORD
638+
# --secret=EROTEMIC_TEST_TWINE_PASSWORD=$EROTEMIC_TEST_TWINE_PASSWORD

.readthedocs.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,30 @@
77

88
# Required
99
version: 2
10+
1011
build:
1112
os: "ubuntu-24.04"
1213
tools:
1314
python: "3.13"
15+
16+
# Build documentation in the docs/ directory with Sphinx
1417
sphinx:
1518
configuration: docs/source/conf.py
19+
20+
# Build documentation with MkDocs
21+
#mkdocs:
22+
# configuration: mkdocs.yml
23+
24+
# Optionally build your docs in additional formats such as PDF and ePub
1625
formats: all
26+
1727
python:
1828
install:
1929
- requirements: requirements/docs.txt
2030
- method: pip
2131
path: .
32+
#extra_requirements:
33+
# - docs
34+
35+
#conda:
36+
# environment: environment.yml

docs/source/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ def visit_Assign(self, node):
141141

142142

143143
project = 'xdoctest'
144-
copyright = '2025, Jon Crall'
144+
copyright = '2026, Jon Crall'
145145
author = 'Jon Crall'
146146
modname = 'xdoctest'
147147

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ requires = [ "setuptools>=41.0.1",]
33
build-backend = "setuptools.build_meta"
44

55
[tool.xcookie]
6-
tags = [ "erotemic", "github", "purepy",]
6+
tags = [ "erotemic", "github", "purepy", "mypy"]
77
mod_name = "xdoctest"
88
repo_name = "xdoctest"
99
rel_mod_parent_dpath = "./src"
@@ -96,6 +96,7 @@ ignore_missing_imports = true
9696

9797
[tool.ty.rules]
9898
unused-type-ignore-comment = "ignore"
99+
unresolved-import = "ignore"
99100

100101
[[tool.ty.overrides]]
101102
include = ["src/xdoctest/_tokenize.py"]

src/xdoctest/__init__.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -321,17 +321,16 @@ def fib(n):
321321
]
322322

323323

324-
from xdoctest import utils
325-
from xdoctest import docstr
326-
from xdoctest.runner import (
327-
doctest_module,
328-
doctest_callable,
329-
)
324+
from xdoctest import docstr, utils
330325
from xdoctest.exceptions import (
331326
DoctestParseError,
327+
ExistingEventLoopError,
332328
ExitTestException,
333329
MalformedDocstr,
334-
ExistingEventLoopError,
330+
)
331+
from xdoctest.runner import (
332+
doctest_callable,
333+
doctest_module,
335334
)
336335

337336
__all__ = [

src/xdoctest/checker.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,11 @@
3535

3636
from __future__ import annotations
3737

38+
import difflib
39+
import re
3840
import typing
3941

40-
import re
41-
import difflib
42-
from xdoctest import utils
43-
from xdoctest import constants
44-
from xdoctest import directive
42+
from xdoctest import constants, directive, utils
4543

4644
unicode_literal_re = re.compile(r'(\W|^)[uU]([rR]?[\'\"])', re.UNICODE)
4745
bytes_literal_re = re.compile(r'(\W|^)[bB]([rR]?[\'\"])', re.UNICODE)

src/xdoctest/constants.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ def __bool__(self) -> bool:
5454

5555
__nonzero__ = __bool__
5656

57+
5758
NOT_EVALED: _NOT_EVAL_TYPE
5859

5960
if 'NOT_EVALED' not in globals():
60-
NOT_EVALED = object.__new__(_NOT_EVAL_TYPE)
61+
NOT_EVALED = object.__new__(_NOT_EVAL_TYPE)

src/xdoctest/core.py

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,25 +22,26 @@
2222

2323
from __future__ import annotations
2424

25-
import typing
26-
27-
import textwrap
28-
import warnings
2925
import itertools as it
30-
import types
3126
import os
32-
from os.path import exists
27+
import textwrap
28+
import types
29+
import typing
30+
import warnings
3331
from fnmatch import fnmatch
34-
from xdoctest import dynamic_analysis
35-
from xdoctest import static_analysis
36-
from xdoctest import parser
37-
from xdoctest import exceptions
38-
from xdoctest import doctest_example
39-
from xdoctest import utils
32+
from os.path import exists
33+
34+
from xdoctest import (
35+
doctest_example,
36+
dynamic_analysis,
37+
exceptions,
38+
global_state,
39+
parser,
40+
static_analysis,
41+
utils,
42+
)
4043
from xdoctest.docstr import docscrape_google
4144
from xdoctest.utils import util_import
42-
from xdoctest import global_state
43-
4445

4546
DOCTEST_STYLES = [
4647
'freeform',
@@ -552,7 +553,8 @@ def package_calldefs(
552553
else:
553554
pkgpath = _rectify_to_modpath(pkg_identifier)
554555
_ideniter = static_analysis.package_modpaths(
555-
pkgpath, with_pkg=True, with_libs=True)
556+
pkgpath, with_pkg=True, with_libs=True
557+
)
556558
identifiers = list(_ideniter)
557559

558560
for module_identifier in identifiers:
@@ -654,7 +656,7 @@ def parse_calldefs(
654656
calldefs = static_analysis.parse_static_calldefs(
655657
fpath=module_identifier
656658
)
657-
659+
658660
assert calldefs is not None
659661
if global_state.DEBUG_CORE: # nocover
660662
print(f'Found {len(calldefs)} calldefs')

0 commit comments

Comments
 (0)