python-sendparcel 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. python_sendparcel-0.1.0/.github/workflows/ci.yml +37 -0
  2. python_sendparcel-0.1.0/.github/workflows/ecosystem-smoke.yml +38 -0
  3. python_sendparcel-0.1.0/.github/workflows/release.yml +23 -0
  4. python_sendparcel-0.1.0/.gitignore +30 -0
  5. python_sendparcel-0.1.0/.pre-commit-config.yaml +39 -0
  6. python_sendparcel-0.1.0/CHANGELOG.md +20 -0
  7. python_sendparcel-0.1.0/CONTRIBUTING.md +77 -0
  8. python_sendparcel-0.1.0/LICENSE +10 -0
  9. python_sendparcel-0.1.0/PKG-INFO +449 -0
  10. python_sendparcel-0.1.0/README.md +397 -0
  11. python_sendparcel-0.1.0/docs/Makefile +12 -0
  12. python_sendparcel-0.1.0/docs/compatibility-matrix.md +13 -0
  13. python_sendparcel-0.1.0/docs/conf.py +43 -0
  14. python_sendparcel-0.1.0/docs/getting-started.md +218 -0
  15. python_sendparcel-0.1.0/docs/index.md +49 -0
  16. python_sendparcel-0.1.0/docs/installation-matrix.md +24 -0
  17. python_sendparcel-0.1.0/docs/provider-authoring.md +40 -0
  18. python_sendparcel-0.1.0/docs/release-policy.md +18 -0
  19. python_sendparcel-0.1.0/docs/requirements.txt +4 -0
  20. python_sendparcel-0.1.0/pyproject.toml +107 -0
  21. python_sendparcel-0.1.0/src/sendparcel/__init__.py +29 -0
  22. python_sendparcel-0.1.0/src/sendparcel/enums.py +24 -0
  23. python_sendparcel-0.1.0/src/sendparcel/exceptions.py +21 -0
  24. python_sendparcel-0.1.0/src/sendparcel/flow.py +164 -0
  25. python_sendparcel-0.1.0/src/sendparcel/fsm.py +131 -0
  26. python_sendparcel-0.1.0/src/sendparcel/protocols.py +41 -0
  27. python_sendparcel-0.1.0/src/sendparcel/provider.py +63 -0
  28. python_sendparcel-0.1.0/src/sendparcel/providers/__init__.py +7 -0
  29. python_sendparcel-0.1.0/src/sendparcel/providers/dummy.py +77 -0
  30. python_sendparcel-0.1.0/src/sendparcel/py.typed +0 -0
  31. python_sendparcel-0.1.0/src/sendparcel/registry.py +70 -0
  32. python_sendparcel-0.1.0/src/sendparcel/types.py +80 -0
  33. python_sendparcel-0.1.0/src/sendparcel/validators.py +20 -0
  34. python_sendparcel-0.1.0/tests/conftest.py +131 -0
  35. python_sendparcel-0.1.0/tests/test_builtin_dummy_provider.py +185 -0
  36. python_sendparcel-0.1.0/tests/test_enums.py +23 -0
  37. python_sendparcel-0.1.0/tests/test_exceptions.py +21 -0
  38. python_sendparcel-0.1.0/tests/test_flow.py +515 -0
  39. python_sendparcel-0.1.0/tests/test_fsm.py +384 -0
  40. python_sendparcel-0.1.0/tests/test_integration.py +289 -0
  41. python_sendparcel-0.1.0/tests/test_protocols.py +34 -0
  42. python_sendparcel-0.1.0/tests/test_provider.py +47 -0
  43. python_sendparcel-0.1.0/tests/test_public_api.py +29 -0
  44. python_sendparcel-0.1.0/tests/test_registry.py +223 -0
  45. python_sendparcel-0.1.0/tests/test_types.py +97 -0
  46. python_sendparcel-0.1.0/tests/test_validators.py +63 -0
  47. python_sendparcel-0.1.0/uv.lock +1195 -0
@@ -0,0 +1,37 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+
8
+ jobs:
9
+ lint:
10
+ runs-on: ubuntu-latest
11
+ steps:
12
+ - uses: actions/checkout@v4
13
+ - uses: astral-sh/setup-uv@v5
14
+ with:
15
+ enable-cache: true
16
+ - run: uv sync --extra dev
17
+ - run: uv run ruff check .
18
+ - run: uv run ruff format --check .
19
+ - run: uv run ty check
20
+
21
+ test:
22
+ runs-on: ubuntu-latest
23
+ strategy:
24
+ matrix:
25
+ python-version: ['3.12', '3.13']
26
+ steps:
27
+ - uses: actions/checkout@v4
28
+ - uses: astral-sh/setup-uv@v5
29
+ with:
30
+ enable-cache: true
31
+ - run: uv python install ${{ matrix.python-version }}
32
+ - run: uv sync --extra dev --python ${{ matrix.python-version }}
33
+ - run: uv run pytest tests/ --cov=sendparcel --cov-report=xml -v
34
+ - uses: codecov/codecov-action@v4
35
+ if: matrix.python-version == '3.12'
36
+ with:
37
+ token: ${{ secrets.CODECOV_TOKEN }}
@@ -0,0 +1,38 @@
1
+ name: Ecosystem smoke
2
+
3
+ on:
4
+ workflow_dispatch:
5
+
6
+ jobs:
7
+ smoke:
8
+ runs-on: ubuntu-latest
9
+ steps:
10
+ - name: Checkout
11
+ uses: actions/checkout@v4
12
+
13
+ - name: Setup uv
14
+ uses: astral-sh/setup-uv@v5
15
+
16
+ - name: Setup Python
17
+ run: uv python install 3.12
18
+
19
+ - name: Install core
20
+ run: uv sync --extra dev
21
+
22
+ - name: Smoke plugin discovery
23
+ run: |
24
+ uv run python - <<'PY'
25
+ from sendparcel.provider import BaseProvider
26
+ from sendparcel.registry import registry
27
+
28
+ class SmokeProvider(BaseProvider):
29
+ slug = "smoke"
30
+ display_name = "Smoke"
31
+
32
+ async def create_shipment(self, **kwargs):
33
+ return {}
34
+
35
+ registry.register(SmokeProvider)
36
+ assert registry.get_by_slug("smoke") is SmokeProvider
37
+ print("plugin discovery smoke ok")
38
+ PY
@@ -0,0 +1,23 @@
1
+ name: Release
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - 'v*'
7
+
8
+ permissions:
9
+ id-token: write
10
+
11
+ jobs:
12
+ release:
13
+ runs-on: ubuntu-latest
14
+ environment: release
15
+ steps:
16
+ - uses: actions/checkout@v4
17
+ - uses: astral-sh/setup-uv@v5
18
+ with:
19
+ enable-cache: true
20
+ - name: Build package
21
+ run: uv build
22
+ - name: Publish to PyPI
23
+ uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,30 @@
1
+ # Python bytecode
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # Virtual environments
7
+ .venv/
8
+ venv/
9
+ env/
10
+
11
+ # Tool caches
12
+ .pytest_cache/
13
+ .ruff_cache/
14
+ .mypy_cache/
15
+ .ty/
16
+ .coverage
17
+ coverage.xml
18
+ htmlcov/
19
+
20
+ # Build artifacts
21
+ build/
22
+ dist/
23
+ *.egg-info/
24
+
25
+ # IDE
26
+ .vscode/
27
+ .idea/
28
+
29
+ # OS
30
+ .DS_Store
@@ -0,0 +1,39 @@
1
+ repos:
2
+ - repo: local
3
+ hooks:
4
+ - id: ruff
5
+ name: ruff
6
+ entry: uv run ruff check --fix
7
+ language: system
8
+ types: [python]
9
+ - id: ruff-format
10
+ name: ruff-format
11
+ entry: uv run ruff format
12
+ language: system
13
+ types: [python]
14
+ - id: check-toml
15
+ name: check-toml
16
+ entry: uv run check-toml
17
+ language: system
18
+ types: [toml]
19
+ - id: check-yaml
20
+ name: check-yaml
21
+ entry: uv run check-yaml
22
+ language: system
23
+ types: [yaml]
24
+ - id: end-of-file-fixer
25
+ name: end-of-file-fixer
26
+ entry: uv run end-of-file-fixer
27
+ language: system
28
+ types: [text]
29
+ - id: trailing-whitespace
30
+ name: trailing-whitespace
31
+ entry: uv run trailing-whitespace-fixer
32
+ language: system
33
+ types: [text]
34
+ - id: ty
35
+ name: ty
36
+ entry: uv run ty check
37
+ language: system
38
+ types: [python]
39
+ pass_filenames: false
@@ -0,0 +1,20 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/).
7
+
8
+ ## [0.1.0] - 2025-02-16
9
+
10
+ ### Added
11
+
12
+ - Provider protocol and plugin registry with entry-point discovery
13
+ - Shipment domain types (`AddressInfo`, `ParcelInfo`, `ShipmentCreateResult`, `LabelInfo`)
14
+ - Finite state machine for shipment lifecycle (`ShipmentStatus` enum with 9 states)
15
+ - Framework-agnostic `ShipmentFlow` orchestrator
16
+ - `BaseProvider` abstract class for provider plugins
17
+ - Built-in `DummyProvider` for testing and development
18
+ - Global and per-provider validator support
19
+ - Async-first runtime powered by `anyio`
20
+ - Full test suite (157 tests)
@@ -0,0 +1,77 @@
1
+ # Contributing to python-sendparcel
2
+
3
+ Thank you for considering a contribution to `python-sendparcel` — the
4
+ framework-agnostic core of the sendparcel ecosystem.
5
+
6
+ ## Prerequisites
7
+
8
+ - Python 3.12 or later
9
+ - [uv](https://docs.astral.sh/uv/) package manager
10
+
11
+ ## Development setup
12
+
13
+ 1. Clone the repository and navigate to the `python-sendparcel` directory.
14
+ 2. Install the project with dev dependencies:
15
+
16
+ ```bash
17
+ uv sync --extra dev
18
+ ```
19
+
20
+ ## Running tests
21
+
22
+ Tests use **pytest** with **pytest-asyncio** (`asyncio_mode = "auto"`).
23
+
24
+ ```bash
25
+ uv run pytest tests/ -q
26
+ ```
27
+
28
+ Always run tests through `uv run` so the correct virtualenv is used.
29
+
30
+ ## Linting and formatting
31
+
32
+ The project uses **ruff** for both linting and formatting:
33
+
34
+ ```bash
35
+ uv run ruff check src tests
36
+ uv run ruff format --check src tests
37
+ ```
38
+
39
+ Static type checking is done with **ty**:
40
+
41
+ ```bash
42
+ uv run --extra dev ty check
43
+ ```
44
+
45
+ ## Code style
46
+
47
+ - All code, comments, docstrings, and messages **must be in English**.
48
+ - Keep APIs **async-first**.
49
+ - Use `anyio` for async primitives and async/sync bridging points.
50
+ - Imports belong at the **top of the file** (PEP 8). Inline imports are
51
+ only acceptable to break a verified circular import, with a comment
52
+ explaining the reason.
53
+ - Follow the ruff rule set configured in `pyproject.toml`
54
+ (`E`, `W`, `F`, `I`, `N`, `UP`, `B`, `A`, `SIM`, `RUF`).
55
+
56
+ ## Pull request process
57
+
58
+ 1. Fork the repository and create a feature branch from `main`.
59
+ 2. Make your changes in small, focused commits.
60
+ 3. Ensure all quality checks pass (tests, linting, formatting, type checks).
61
+ 4. Open a pull request against `main` with a clear description of your
62
+ changes.
63
+
64
+ ## Commit messages
65
+
66
+ - Use the **imperative mood** ("Add feature", not "Added feature").
67
+ - Keep the subject line concise (72 characters or fewer).
68
+ - Reference related issues when applicable (e.g., `Fix #42`).
69
+
70
+ ## Ecosystem rules
71
+
72
+ - Keep APIs async-first.
73
+ - Use `anyio` for async primitives and async/sync bridging points.
74
+ - Preserve plugin compatibility with `python-sendparcel` core contracts —
75
+ framework adapters (`django-sendparcel`, `fastapi-sendparcel`,
76
+ `litestar-sendparcel`) depend on stable public interfaces.
77
+ - Any change to a public API must be reflected in the adapter packages.
@@ -0,0 +1,10 @@
1
+
2
+ MIT License
3
+
4
+ Copyright (c) 2025, Dominik Kozaczko
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
7
+
8
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
9
+
10
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.