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
2 changes: 1 addition & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Documentation
name: Deploy Documentation

# build the documentation whenever there are new commits on main
on:
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ on:
branches: [ main ]
workflow_call:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
test:
runs-on: ubuntu-latest
Expand Down
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ publish*.bat
publish*.cmd
publish*.sh

# Ignore all of these extensions in root
## Ignore all of these extensions in root
/*.stl
/*.step
/*.dxf
Expand All @@ -15,6 +15,9 @@ publish*.sh
/*.yaml
/*.py

### Except
!/.pre-commit-config.yaml

### Python ###
# Byte-compiled / optimized / DLL files
__pycache__/
Expand Down
27 changes: 27 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
repos:
- repo: https://github.com/astral-sh/uv-pre-commit
# uv version
rev: 0.7.13
hooks:
- id: uv-lock
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.11.12
hooks:
# Run the linter.
- id: ruff-check
types_or: [ python, pyi ]
args: [ --fix ]
# Run the formatter.
- id: ruff-format
types_or: [ python, pyi ]
- repo: https://github.com/codespell-project/codespell
rev: v2.4.1
hooks:
- id: codespell
additional_dependencies:
- tomli
2 changes: 0 additions & 2 deletions examples/ergogen/main.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# ruff: noqa: F403, F405

import logging
from pathlib import Path

Expand Down
2 changes: 0 additions & 2 deletions examples/filleting/main.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# ruff: noqa: F403, F405

import logging
from pathlib import Path

Expand Down
2 changes: 0 additions & 2 deletions examples/panel/main.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# ruff: noqa: F403, F405

import logging
from pathlib import Path

Expand Down
4 changes: 1 addition & 3 deletions examples/skewed/main.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# ruff: noqa: F403, F405

import logging
from pathlib import Path

Expand Down Expand Up @@ -48,7 +46,7 @@

cap_count = 4

for i in range(cap_count - 1):
for _ in range(cap_count - 1):
cap = caps[-1].mirrored()
cap.locate(caps[-1].top_right * Pos(gap))
caps.append(cap)
Expand Down
4 changes: 1 addition & 3 deletions examples/slanted/main.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# ruff: noqa: F403, F405

import logging
from pathlib import Path

Expand Down Expand Up @@ -48,7 +46,7 @@

cap_count = 4

for i in range(cap_count - 1):
for _ in range(cap_count - 1):
last = caps[-1]
cap = last.clone()
cap.length = last.right.length
Expand Down
2 changes: 0 additions & 2 deletions examples/surface/main.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# ruff: noqa: F403, F405

import logging
from pathlib import Path

Expand Down
2 changes: 0 additions & 2 deletions examples/trapezoid/main.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# ruff: noqa: F403, F405

import logging
from pathlib import Path

Expand Down
48 changes: 46 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[project]
name = "capistry"
version = "0.1.0"
Expand All @@ -15,7 +19,7 @@ requires-python = ">=3.13"
dependencies = [
"build123d>=0.9.1,<1",
"rich>=14.0.0,<15",
"mashumaro>=3.16,<4",
"mashumaro>=3.16,<4",
"more-itertools>=10.7.0,<11",
"attrs>=25.3.0,<26",
"tzdata>=2025.2",
Expand All @@ -41,8 +45,46 @@ Issues = "https://github.com/larssont/capistry/issues"

[tool.ruff]
line-length = 100
ignore = ["F403", "F405", "E731"]

[tool.ruff.lint]
select = [
"D",
"B", # flake8-bugbear
"TC", # flake8-type-checking
"C4", # Helps you write better list/set/dict comprehensions.
"E", # pycodestyle errors
"FA", # Verifies files use from __future__ import annotations if a type is used in the module that can be rewritten using PEP 563.
"F", # pyflakes
"G", # Better usage of built-in logging
"I", # isort - Import sorting
"LOG", # Checks for issues using the standard library logging module.
"PL", # pylint
"PYI", # Linting rules for type annotations.
"Q", # Linting rules for quites
"RUF", # Ruff lint
"TID", # Helps you write tidier imports.
"UP", # pyupgrade
"W", # pycodestyle warnings
"SIM", # flake8-simplify
"TRY", # Tryceratops - For those who like dinosaurs 🦖 and clean try/except ✨ blocks.
]

ignore = [
"TRY003" # Checks for long exception messages that are not defined in the exception class itself.
]

[tool.ruff.lint.per-file-ignores]
"src/tests/**/*.py" = ["PLR2004", "D", "PLR0913"]
"examples/**/*.py" = ["PLR2004", "D", "F403", "F405"]

[tool.ruff.lint.pydocstyle]
convention = "numpy"

[tool.codespell]
skip = "*.lock, *.step"
count = true
quiet-level = 3
ignore-words-list = "strat"

[dependency-groups]
dev = [
Expand All @@ -56,6 +98,8 @@ dev = [
"pylint",
"pdoc",
"ocp_vscode",
"codespell",
"pre-commit"
]

[tool.basedpyright]
Expand Down
14 changes: 7 additions & 7 deletions src/capistry/_math.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def polygon_width(n, radius, inradius=True):
ValueError
If n < 3 (polygon must have at least 3 sides).
"""
if n < 3:
if n < 3: # noqa: PLR2004
raise ValueError("Polygon must have at least 3 sides.")

angle = pi / n
Expand Down Expand Up @@ -142,16 +142,16 @@ def polygon_height(n, radius, inradius=True):
For even-sided polygons, the height is twice the inradius.
For odd-sided polygons, the height is the sum of inradius and circumradius.
"""
if n < 3:
if n < 3: # noqa: PLR2004
raise ValueError("Polygon must have at least 3 sides.")

actual_inradius = radius if inradius else radius * cos(pi / n)

if n % 2 == 0:
return 2 * actual_inradius
else:
circumradius = radius / cos(pi / n) if inradius else radius
return actual_inradius + circumradius

circumradius = radius / cos(pi / n) if inradius else radius
return actual_inradius + circumradius


def polygon_area(n, radius, inradius=False):
Expand Down Expand Up @@ -179,7 +179,7 @@ def polygon_area(n, radius, inradius=False):
ValueError
If n < 3 (polygon must have at least 3 sides).
"""
if n < 3:
if n < 3: # noqa: PLR2004
raise ValueError("Polygon must have at least 3 sides.")

if inradius:
Expand Down Expand Up @@ -217,7 +217,7 @@ def polygon_prism_surface(n, radius, height, inradius=False):
ValueError
If n < 3 (polygon must have at least 3 sides).
"""
if n < 3:
if n < 3: # noqa: PLR2004
raise ValueError("Polygon must have at least 3 sides.")

base_area = polygon_area(n, radius, inradius)
Expand Down
Loading