Skip to content
Open
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
18 changes: 18 additions & 0 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Python Rules

- Where possible, prefer duck-typing tests than `isinstance`, e.g. `hasattr(x, attr)` not `isinstance(x, SpecificClass)`
- Use modern Python 3.9+ syntax
- Prefer f-strings for formatting strings rather than `.format` or `%` formatting
- When creating log statements, never use runtime string formatting. Use the `extra` argument and % placeholders in the log message
- When generating union types, use the union operator, `|` , not the `typing.Union` type
- When merging dictionaries, use the union operator
- When writing type hints for standard generics like `dict`, `list`, `tuple`, use the PEP-585 spec, not `typing.Dict`, `typing.List`, etc.
- Use type annotations in function and method signatures, unless the rest of the code base does not have type signatures
- Do not add inline type annotations for local variables when they are declared and assigned in the same statement.
- Prefer `pathlib` over `os.path` for operations like path joining
- When using `open()` in text-mode, explicitly set `encoding` to `utf-8`
- Prefer `argparse` over `optparse`
- Use the builtin methods in the `itertools` module for common tasks on iterables rather than creating code to achieve the same result
- When creating dummy data, don't use "Foo" and "Bar", be more creative
- When creating dummy data in strings like names don't just create English data, create data in a range of languages like English, Spanish, Mandarin, and Hindi
- When asked to create a function, class, or other piece of standalone code, don't append example calls unless otherwise told to
118 changes: 118 additions & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
name: main

on:
push:
branches: [main, test-me-*]
tags: ["*"]
pull_request:

jobs:
test:
strategy:
matrix:
python-version:
- "3.9"
- "3.10"
- "3.11"
- "3.12"
- "3.13"
platform:
- ubuntu-latest
# - macos-latest
# - windows-latest
runs-on: ${{ matrix.platform }}
env:
UV_PYTHON: ${{ matrix.python-version }}
steps:
- uses: actions/checkout@v4

- name: Install uv and set the python version
uses: astral-sh/setup-uv@v6

- name: Install the project
run: uv sync --extra tests
# run: uv sync --locked --all-extras --dev

- name: Run tests
run: uv run pytest tests

build:
name: Build distribution 📦
needs:
- test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Install uv and set the python version
uses: astral-sh/setup-uv@v6

- name: Build package
run: uv build

- name: Store the distribution packages
uses: actions/upload-artifact@v4
with:
name: python-package-distributions
path: dist/

publish-to-pypi:
name: upload release to PyPI
if: ${{ startsWith(github.ref, 'refs/tags/') }} # only publish to PyPI on tag pushes
needs:
- build
runs-on: ubuntu-latest
environment: pypi
permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing

steps:
- name: Download all the dists
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1

github-release:
name: Sign the Python 🐍 distribution 📦 with Sigstore and upload them to GitHub Release
if: ${{ startsWith(github.ref, 'refs/tags/') }} # only publish to GitHub Releases on tag pushes
needs:
- build
runs-on: ubuntu-latest

permissions:
contents: write # IMPORTANT: mandatory for making GitHub Releases
id-token: write # IMPORTANT: mandatory for sigstore

steps:
- name: Download all the dists
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/
- name: Sign the dists with Sigstore
uses: sigstore/gh-action-sigstore-python@v3.0.0
with:
inputs: >-
./dist/*.tar.gz
./dist/*.whl
- name: Create GitHub Release
env:
GITHUB_TOKEN: ${{ github.token }}
run: >-
gh release create
'${{ github.ref_name }}'
--repo '${{ github.repository }}'
--generate-notes
- name: Upload artifact signatures to GitHub Release
env:
GITHUB_TOKEN: ${{ github.token }}
# Upload to GitHub Release using the `gh` CLI.
# `dist/` contains the built packages, and the
# sigstore-produced signatures and certificates.
run: >-
gh release upload
'${{ github.ref_name }}' dist/**
--repo '${{ github.repository }}'
20 changes: 0 additions & 20 deletions .github/workflows/main.yml

This file was deleted.

31 changes: 21 additions & 10 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,12 @@ ipython_config.py
# install all needed dependencies.
#Pipfile.lock

# UV
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
#uv.lock

# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
Expand All @@ -106,8 +112,10 @@ ipython_config.py
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/#use-with-ide
# https://pdm.fming.dev/latest/usage/project/#working-with-version-control
.pdm.toml
.pdm-python
.pdm-build/

# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/
Expand Down Expand Up @@ -159,13 +167,16 @@ cython_debug/
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/

*.prof
# Ruff stuff:
.ruff_cache/

# PyPI configuration file
.pypirc
_version.py
__TEMP_LAMBDA_DEV_SERVER_HELPER_DO_NOT_CHECK_INTO_GIT__*
temp/
.DS_Store
v
launch.json
.vscode
_geckobuild
.ruff_cache
.trunk
src/comma/_version.py
temp
*.dist-info/

uv.lock
requirements.txt
83 changes: 56 additions & 27 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,28 +1,33 @@
ci:
skip:
- hatch-test
- taplo
# - tox
- uv-lock
- taplo-lint
- uv-mypy
- uv-pyrefly
- uv-ty
- uv-pyright
- uv-test
repos:
- repo: https://github.com/ComPWA/mirrors-taplo
rev: "v0.8.1"
- repo: https://github.com/astral-sh/uv-pre-commit
rev: 0.8.4
hooks:
- id: taplo
- repo: https://github.com/asottile/reorder-python-imports
rev: v3.12.0
- id: uv-lock
- id: uv-export
- repo: https://github.com/ComPWA/mirrors-taplo
rev: "v0.9.3"
hooks:
- id: reorder-python-imports
args: [--py37-plus, --add-import, "from __future__ import annotations"]
- id: taplo-format
- id: taplo-lint
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.3.3
rev: v0.12.7
hooks:
- id: ruff
- id: ruff-check
types_or: [python, pyi, jupyter]
args: [--fix]
- id: ruff-format
types_or: [python, pyi, jupyter]
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
rev: v5.0.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
Expand All @@ -31,24 +36,48 @@ repos:
- id: name-tests-test
- id: requirements-txt-fixer
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.9.0
rev: v1.17.1
hooks:
- id: mypy
additional_dependencies: [types-all]
additional_dependencies:
- types-requests
- repo: local
hooks:
- id: hatch-test
name: hatch-test
entry: env HATCH_ENV_TYPE_VIRTUAL_PATH='' hatch run --parallel all:test
- id: uv-mypy
name: uv-mypy
entry: env VIRTUAL_ENV= uv run --extra types mypy
args: [--ignore-missing-imports, --scripts-are-modules]
language: python
'types_or': [python, pyi]
require_serial: true
additional_dependencies: [uv]
- id: uv-pyrefly
name: uv-pyrefly
entry: env VIRTUAL_ENV= uv run --extra types pyrefly check
language: python
'types_or': [python, pyi]
require_serial: true
additional_dependencies: [uv]
- id: uv-ty
name: uv-ty
entry: env VIRTUAL_ENV= uv run --extra types ty check
language: python
'types_or': [python, pyi]
require_serial: true
additional_dependencies: [uv]
stages: [manual]
- id: uv-pyright
name: uv-pyright
entry: env VIRTUAL_ENV= uv run --extra types pyright
language: python
'types_or': [python, pyi]
require_serial: true
additional_dependencies: [uv]
- id: uv-test
name: uv-test
entry: env VIRTUAL_ENV= uv run --extra tests pytest
language: python
additional_dependencies: [hatch]
types: [python]
pass_filenames: false
always_run: true
# - id: tox
# name: tox
# entry: tox run-parallel
# language: python
# additional_dependencies: ["tox"]
# pass_filenames: false
# always_run: true
# types: [python]
additional_dependencies: [uv]
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.9
37 changes: 37 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"ruff.lint.args": ["--unsafe-fixes"],

"[python]": {
"editor.formatOnSave": true,
"editor.defaultFormatter": "charliermarsh.ruff",
"editor.codeActionsOnSave": {
"source.fixAll": "explicit",
"source.organizeImports": "never",
"source.organizeImports.reorder-python-imports": "explicit"
}
},
"ruff.organizeImports": false,

"notebook.formatOnSave.enabled": true,
"notebook.codeActionsOnSave": {
"source.fixAll": true,
"source.organizeImports": false,
"source.organizeImports.reorder-python-imports": true
},

"reorder-python-imports.args": [
"--application-directories=.:src",
"--add-import 'from __future__ import annotations'"
],
"python.analysis.diagnosticSeverityOverrides": {
"reportShadowedImports": "none"
},
"python.testing.pytestArgs": [
"tests"
],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true,
"python.analysis.typeCheckingMode": "basic",
"explorer.excludeGitIgnore": true,
"python.analysis.autoImportCompletions": true
}
9 changes: 9 additions & 0 deletions cookiecutter.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"project_name": "comma-cli",
"project_slug": "comma",
"project_short_description": "Multi-Tool",
"minimum_python_version": "3.9",
"full_name": "Flavio Amurrio",
"email": "25621374+FlavioAmurrioCS@users.noreply.github.com",
"github_username": "FlavioAmurrioCS"
}
Loading
Loading