Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typesafe Splipy, again #175

Open
wants to merge 29 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
b7194a3
Autoformat (ruff)
TheBB Feb 8, 2024
3adb1c8
Fix some linter complaints
TheBB Feb 8, 2024
253d641
Mypy type safety: round 1
TheBB Feb 10, 2024
970268e
Mypy type safety: round 2
TheBB Feb 12, 2024
2667610
Fix failure on Py3.9
TheBB Feb 12, 2024
8bf414c
STL: knots aren't lists!
TheBB Feb 13, 2024
76322c9
Mypy type safety: round 3
TheBB Feb 13, 2024
3e5ff4e
Mypy type safety: round 4
TheBB Feb 13, 2024
ac28286
Mypy type safety: round 5
TheBB Feb 13, 2024
bc6c147
Fix splipy.io optional imports
TheBB Feb 13, 2024
b014a08
Mypy type safety: round 6
TheBB Feb 14, 2024
316e63d
Mypy type safety: round 7
TheBB Feb 14, 2024
e3b5492
Mypy type safety: round 8
TheBB Feb 15, 2024
195e0a5
Mypy type safety: round 9
TheBB Feb 15, 2024
71a2711
Mypy type safety: round 10
TheBB Feb 15, 2024
78b669a
Mypy type safety: round 11
TheBB Feb 16, 2024
3938805
Add a large variety of linter rules
TheBB Feb 16, 2024
dad7960
Update README.md
TheBB Feb 16, 2024
c3eceab
Add some dev dependencies
TheBB Feb 16, 2024
0b323d8
Set mypy path in pyproject.toml
TheBB Feb 16, 2024
6f26736
Fix nutils stub file
TheBB Feb 16, 2024
0298df6
Drop getargspec in favor of getfullargspec
TheBB Feb 16, 2024
5ad0e15
Fix io module conditional imports
TheBB Feb 16, 2024
d5c16cc
Fix GRDECL bug
TheBB Feb 16, 2024
f967485
Add h5py to dev group
TheBB Feb 16, 2024
209e39b
Add tqdm to dev group
TheBB Feb 16, 2024
18ec9d9
Reformat
TheBB Feb 16, 2024
911572a
Fix int/intp confusion
TheBB Feb 16, 2024
c256608
Update actions workflow
TheBB Feb 21, 2024
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
44 changes: 25 additions & 19 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,19 @@ name: Python package
on:
push:
branches: [ master ]
tags: ['*']
pull_request:
branches: [ master ]
create:
tags:
workflow_dispatch:

jobs:

debug:
name: Debug
runs-on: ubuntu-latest
steps:
- uses: hmarr/debug-action@v3

test:
name: Test
runs-on: ${{ matrix.os }}
Expand All @@ -19,9 +24,9 @@ jobs:
python-version: ['3.9', '3.10', '3.11', '3.12']
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
Expand All @@ -40,14 +45,14 @@ jobs:
name: Build wheels
needs: [test]
runs-on: ${{ matrix.os }}
if: github.event_name == 'create' && startsWith(github.ref, 'refs/tags/v') || github.event_name == 'workflow_dispatch'
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') || github.event_name == 'workflow_dispatch'
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.9'
- name: Install dependencies
Expand All @@ -59,41 +64,42 @@ jobs:
env:
CIBW_BUILD: cp39-* cp310-* cp311-* cp312-*
CIBW_SKIP: '*musllinux* *i686*'
# CIBW_BEFORE_BUILD: pip install -r requirements.dev.txt
- uses: actions/upload-artifact@v3
with:
name: wheels-${{ matrix.os }}
path: ./wheelhouse/*.whl

build_sdist:
name: Build sdist
needs: [test]
runs-on: ubuntu-latest
if: github.event_name == 'create' && startsWith(github.ref, 'refs/tags/v') || github.event_name == 'workflow_dispatch'
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') || github.event_name == 'workflow_dispatch'
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.9'
- name: Install dependencies
run: |
python -m pip install --upgrade pip wheel poetry
- name: Build sdist
run: make sdist
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: sdist
path: ./dist/*.tar.gz

deploy:
name: Deploy
needs: [build_wheels, build_sdist]
runs-on: ubuntu-latest
if: github.event_name == 'create' && startsWith(github.ref, 'refs/tags/v')
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
steps:
- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4
with:
name: artifact
path: dist
merge-multiple: true
- uses: pypa/[email protected]
with:
user: __token__
Expand All @@ -105,10 +111,10 @@ jobs:
runs-on: ubuntu-latest
if: github.event_name == 'workflow_dispatch'
steps:
- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4
with:
name: artifact
path: dist
merge-multiple: true
- uses: pypa/[email protected]
with:
user: __token__
Expand Down
47 changes: 29 additions & 18 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,36 +1,47 @@
.PHONY: install mypy lint fmt fmtcheck doc
package := splipy

install:
poetry install --with=dev

mypy:
poetry run mypy splipy
# Convenience targets

lint:
poetry run ruff splipy
.PHONY: install
install:
poetry install --with=dev

bench:
poetry run pytest --benchmark-only
.PHONY: doc
doc:
$(MAKE) -C doc html

fmt:
poetry run black splipy
poetry run isort splipy

fmtcheck:
poetry run black splipy --check
poetry run isort splipy --check
# Linting targets

.PHONY: format
format:
poetry run ruff format $(package)

doc:
$(MAKE) -C doc html
.PHONY: lint
lint:
poetry run ruff check --fix $(package)


# Test targets

.PHONY:
benchmark:
poetry run pytest --benchmark-only

.PHONY: pytest
pytest:
poetry run pytest --benchmark-skip

.PHONY: mypy
mypy:
poetry run mypy

.PHONY: lint-check
lint-check:
poetry run ruff check $(package)
poetry run ruff format --check $(package)

.PHONY: examples
examples:
poetry run python examples/circle_animation.py --ci
Expand All @@ -42,7 +53,7 @@ examples:
poetry run python examples/write.py

.PHONY: test # most common test commands for everyday development
test: pytest
test: pytest mypy lint-check

.PHONY: test-all # run from CI: the whole kitchen sink
test-all: test examples
Expand Down
36 changes: 24 additions & 12 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,30 @@ Don't upload wheels to PyPI manually. They are built by CI runners whenever a
new version is tagged (see below).


Tests
-----

To run the tests, use::

make test

To run specific parts of the tests, use::

make pytest
make mypy
make lint-check

The lint-check stage of the tests will complain about linter and style errors.
Some of these can be fixed automatically. To do this, run::

make lint
make format

For benchmarks::

make benchmark


Documentation
-------------

Expand All @@ -89,18 +113,6 @@ To push generated docs online on the ``gh-pages`` branch, run the helper script:
where ``remote`` is the name of the remote to push to. If not given, it will be asked.


Tests
-----

To run the tests, use::

make test

For benchmarks::

make bench


Releasing
---------

Expand Down
2 changes: 1 addition & 1 deletion examples/write.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@


# G2 files are native GoTools (http://www.sintef.no/projectweb/geometry-toolkits/gotools/)
with G2('torus.g2') as my_file:
with G2('torus.g2', 'w') as my_file:
my_file.write(torus)
Loading