Skip to main content

🔧 Pre-commit Hooks

Reusable pre-commit hooks for OpenSCAD projects.

Published on PyPI as kellerlab-pre-commit-hooks.

📌 What

Two hooks for OpenSCAD-based 3D printing projects:

Hook Description
flatten-validate Runs scadm flatten --all and fails if flattened files have uncommitted changes
optimize-images Resizes oversized JPEGs/PNGs, compresses them, and strips metadata (privacy)

🔧 Usage

Add to your .pre-commit-config.yaml:

- repo: https://github.com/kellerlabs/pre-commit-hooks
  rev: v0.1.0  # use latest tag
  hooks:
    - id: flatten-validate
    - id: optimize-images

flatten-validate

Flattens OpenSCAD files via scadm and validates that the output is committed. Reads flatten config from scadm.json automatically.

- id: flatten-validate
  # Override trigger pattern (default: always_run)
  always_run: false
  files: '^(scadm\.json|models/.*\.scad)'

Options:

Arg Default Description
--flatten-dir Read from scadm.json Override flatten output dirs (list of paths/globs)

optimize-images

Resizes JPEGs and PNGs exceeding max width, compresses them, and strips metadata. EXIF data (including GPS coordinates) is removed from JPEGs; text metadata chunks are removed from PNGs.

- id: optimize-images
  args: [--max-width=1920, --quality=85]

Options:

Arg Default Description
--max-width 1920 Maximum image width in pixels
--quality 85 JPEG compression quality (1-95, ignored for PNG)

Both hooks fail when files are modified, printing instructions to git add the changes. Re-run git commit after staging.

🏗️ Used In

🤝 Contributing

See CONTRIBUTING.md.

📜 License

MIT

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

kellerlab_pre_commit_hooks-0.3.11.tar.gz (8.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

kellerlab_pre_commit_hooks-0.3.11-py3-none-any.whl (7.0 kB view details)

Uploaded Python 3

File details

Details for the file kellerlab_pre_commit_hooks-0.3.11.tar.gz.

File metadata

File hashes

Hashes for kellerlab_pre_commit_hooks-0.3.11.tar.gz
Algorithm Hash digest
SHA256 8589514eb7dcc8b1eb3b533bb2936f1360a88cd2a261c868c0593a0821c4ecdf
MD5 616fbd17b3a2e446715c4687790d059f
BLAKE2b-256 fd3c45a1ee05348a602d53d19fdafe3fea97298fe7763933baa83f1925284981

See more details on using hashes here.

Provenance

The following attestation bundles were made for kellerlab_pre_commit_hooks-0.3.11.tar.gz:

Publisher: publish.yml on kellerlabs/pre-commit-hooks

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file kellerlab_pre_commit_hooks-0.3.11-py3-none-any.whl.

File metadata

File hashes

Hashes for kellerlab_pre_commit_hooks-0.3.11-py3-none-any.whl
Algorithm Hash digest
SHA256 ccd70881cd011f22893fc208560c3ffe0ef3ec150761af2e8bba9aca36620e2a
MD5 2a0367909ff4e2aee4f4a3c26d455949
BLAKE2b-256 93078a27038232f5dec695ea48005c2f0f8aeba651e2963e4d00e604f93ca57d

See more details on using hashes here.

Provenance

The following attestation bundles were made for kellerlab_pre_commit_hooks-0.3.11-py3-none-any.whl:

Publisher: publish.yml on kellerlabs/pre-commit-hooks

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.3.11 This release

2 files

0.3.10

2 files

0.3.9

2 files

0.3.8

2 files

0.3.7

2 files

0.3.6

2 files

0.3.5

2 files

0.3.4

2 files

0.3.3

2 files

0.3.2

2 files

0.3.1

2 files

0.3.0

2 files

0.2.3

2 files

0.2.2

2 files

0.2.1

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page