Skip to content

Commit 9820fc6

Browse files
authored
Add tests to CI; fix a few minor things (#2)
* Adding PyTest runs to Github Actions. * Switching `.unwrap()` to `?` to work better with Rust error handling. * Intern some commonly used strings. * Move away from explicit `panic!`
1 parent 1718893 commit 9820fc6

File tree

7 files changed

+231
-53
lines changed

7 files changed

+231
-53
lines changed

.github/workflows/CI.yml

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,25 @@ permissions:
1818
contents: read
1919

2020
jobs:
21+
test:
22+
runs-on: ${{matrix.os}}
23+
strategy:
24+
matrix:
25+
os: [ macos-latest, ubuntu-latest, windows-latest ]
26+
version: [ '3.9', '3.10', '3.11', '3.12', '3.13' ]
27+
steps:
28+
- uses: actions/checkout@v4
29+
- uses: actions/setup-python@v5
30+
with:
31+
python-version: ${{ matrix.version }}
32+
- name: Install uv
33+
uses: astral-sh/setup-uv@v5
34+
- name: Run tests
35+
run: uv run pytest
36+
2137
linux:
2238
runs-on: ${{ matrix.platform.runner }}
39+
needs: [ test ]
2340
strategy:
2441
matrix:
2542
platform:
@@ -62,6 +79,7 @@ jobs:
6279

6380
musllinux:
6481
runs-on: ${{ matrix.platform.runner }}
82+
needs: [ test ]
6583
strategy:
6684
matrix:
6785
platform:
@@ -100,6 +118,7 @@ jobs:
100118

101119
windows:
102120
runs-on: ${{ matrix.platform.runner }}
121+
needs: [ test ]
103122
strategy:
104123
matrix:
105124
platform:
@@ -119,12 +138,13 @@ jobs:
119138
target: ${{ matrix.platform.target }}
120139
args: --release --out dist
121140
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
122-
- name: Build free-threaded wheels
123-
uses: PyO3/maturin-action@v1
124-
with:
125-
target: ${{ matrix.platform.target }}
126-
args: --release --out dist -i python3.13t
127-
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
141+
# TODO: fix this for Windows
142+
# - name: Build free-threaded wheels
143+
# uses: PyO3/maturin-action@v1
144+
# with:
145+
# target: ${{ matrix.platform.target }}
146+
# args: --release --out dist -i python3.13t
147+
# sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
128148
- name: Upload wheels
129149
uses: actions/upload-artifact@v4
130150
with:
@@ -133,6 +153,7 @@ jobs:
133153

134154
macos:
135155
runs-on: ${{ matrix.platform.runner }}
156+
needs: [ test ]
136157
strategy:
137158
matrix:
138159
platform:

.gitignore

Lines changed: 142 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,149 @@ target/
1313
# Contains mutation testing data
1414
**/mutants.out*/
1515

16-
# RustRover
16+
# PyCharm/RustRover
1717
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
1818
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
1919
# and can be added to the global gitignore or merged into this file. For a more nuclear
2020
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
21-
.idea/
21+
.idea/
22+
23+
# Byte-compiled / optimized / DLL files
24+
__pycache__/
25+
*.py[cod]
26+
*$py.class
27+
28+
# C extensions
29+
*.so
30+
31+
# Distribution / packaging
32+
.Python
33+
build/
34+
develop-eggs/
35+
dist/
36+
downloads/
37+
eggs/
38+
.eggs/
39+
lib/
40+
lib64/
41+
parts/
42+
sdist/
43+
var/
44+
wheels/
45+
share/python-wheels/
46+
*.egg-info/
47+
.installed.cfg
48+
*.egg
49+
MANIFEST
50+
51+
# PyInstaller
52+
# Usually these files are written by a python script from a template
53+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
54+
*.manifest
55+
*.spec
56+
57+
# Installer logs
58+
pip-log.txt
59+
pip-delete-this-directory.txt
60+
61+
# Unit test / coverage reports
62+
htmlcov/
63+
.tox/
64+
.nox/
65+
.coverage
66+
.coverage.*
67+
.cache
68+
nosetests.xml
69+
coverage.xml
70+
*.cover
71+
*.py,cover
72+
.hypothesis/
73+
.pytest_cache/
74+
cover/
75+
76+
# Translations
77+
*.mo
78+
*.pot
79+
80+
# Django stuff:
81+
*.log
82+
local_settings.py
83+
db.sqlite3
84+
db.sqlite3-journal
85+
86+
# Flask stuff:
87+
instance/
88+
.webassets-cache
89+
90+
# Scrapy stuff:
91+
.scrapy
92+
93+
# Sphinx documentation
94+
docs/_build/
95+
96+
# PyBuilder
97+
.pybuilder/
98+
target/
99+
100+
# Jupyter Notebook
101+
.ipynb_checkpoints
102+
103+
# IPython
104+
profile_default/
105+
ipython_config.py
106+
107+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
108+
__pypackages__/
109+
110+
# Celery stuff
111+
celerybeat-schedule
112+
celerybeat.pid
113+
114+
# SageMath parsed files
115+
*.sage.py
116+
117+
# Environments
118+
.env
119+
.venv
120+
env/
121+
venv/
122+
ENV/
123+
env.bak/
124+
venv.bak/
125+
126+
# Spyder project settings
127+
.spyderproject
128+
.spyproject
129+
130+
# Rope project settings
131+
.ropeproject
132+
133+
# mkdocs documentation
134+
/site
135+
136+
# mypy
137+
.mypy_cache/
138+
.dmypy.json
139+
dmypy.json
140+
141+
# Pyre type checker
142+
.pyre/
143+
144+
# pytype static type analyzer
145+
.pytype/
146+
147+
# Cython debug symbols
148+
cython_debug/
149+
150+
# Visual Studio Code
151+
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
152+
# that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
153+
# and can be added to the global gitignore or merged into this file. However, if you prefer,
154+
# you could uncomment the following to ignore the entire vscode folder
155+
.vscode/
156+
157+
# Ruff stuff:
158+
.ruff_cache/
159+
160+
# PyPI configuration file
161+
.pypirc

src/singledispatch/builtins.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ impl Builtins {
3939
) -> PyResult<bool> {
4040
let args = PyTuple::new(py, [cls, typ]);
4141
match self.issubclass_func.call1(py, args?) {
42-
Ok(result) => Ok(result.downcast_bound::<PyBool>(py).unwrap().is_true()),
42+
Ok(result) => Ok(result.downcast_bound::<PyBool>(py)?.is_true()),
4343
Err(e) => Err(e),
4444
}
4545
}

0 commit comments

Comments
 (0)