| alwaysApply | true |
|---|
This document provides context and guidelines for Claude AI when working on the pipe-operator project.
pyproject.toml- Project config, dependencies, tool settings, type-checker overridesCONTRIBUTING.md- Setup and QA instructionsCHANGELOG.md- Version history (update TBD section for unreleased changes).githooks/pre-commit- Pre-commit validation script (7 steps).flake8- Flake8 config (ignores: W503, F821, E501, E704; max-line-length: 88)
pipe-operator is a Python library that brings Elixir's pipe operator functionality to Python. It provides two main implementations:
- Elixir Flow: Mimics Elixir's
|>operator using Python's>>operator - Python Flow: A more Pythonic approach using chaining
The project focuses on type safety, code quality, and compatibility across multiple Python versions (3.9-3.14).
- Language: Python 3.9+
- Package Manager: uv
- Type Checkers: mypy, pyright, ty, pyrefly
- Linters: ruff, flake8
- Testing: unittest with coverage (minimum 90%)
- Build: setuptools
pipe_operator/
├── pipe_operator/ # Main package
│ ├── elixir_flow/ # Elixir-style pipe implementation
│ ├── python_flow/ # Python-style chaining implementation
│ └── shared/ # Shared utilities and exceptions
├── .githooks/ # Git hooks for pre-commit checks
├── .github/ # CI/CD workflows
└── pyproject.toml # Project configuration and dependencies# Full QA (mirrors pre-commit hook)
ruff check --select I . && ruff check . && ruff format --check .
flake8 .
mypy .
pyright .
ty check . --error-on-warning
pyrefly check .
coverage run -m unittest discover . && coverage report --fail-under=90Code must work on Python 3.9 through 3.14. Avoid Python 3.10+ only features.
Anti-patterns - DO NOT USE:
match/casestatements (Python 3.10+)|operator for type unions in annotations (useUnion[A, B]instead)- Structural pattern matching
TypeAliaswithoutfrom typing_extensions import TypeAliasSelftype withoutfrom typing_extensions import Self- Built-in generic types in annotations like
list[int](useList[int])
Correct patterns:
- Use
Union[A, B]orOptional[A]for type unions - Use
List,Dict,Set,Tuplefromtypingmodule - Use
if/elif/elseinstead of match statements - Import from
typing_extensionsfor newer type features
- All functions must have complete type annotations
- Use specific types, avoid
Anyunless absolutely necessary - Compatible with mypy, pyright, ty, and pyrefly (all four must pass)
- Never use
type: ignorewithout justification - Some test files have special type checking overrides (see
pyproject.toml)
- Write comprehensive unit tests for all new code
- Maintain at least 90% code coverage (enforced)
- Tests located in
tests/subdirectories ortests.pyfiles alongside source - Use unittest framework
- Use ruff for formatting (runs automatically via hooks)
- Follow PEP 8 guidelines
- Use double quotes for strings
- Descriptive variable names
- Use
# region ClassNamecomments to separate classes in a file - Use
__slots__on all classes - Imports: stdlib first, then
typing_extensions, then internal (pipe_operator.) - Internal imports use explicit relative paths (e.g.,
from .classes import ...) __init__.pyfiles re-export with aliases (e.g.,PipeObject as start) and define__all__- Custom exception:
PipeErrorinpipe_operator.shared.exceptions
- PostToolUse (Write|Edit): Auto-runs
ruff format+ruff check --fix --select Ion changed files - Stop: Runs
mypy .(first 20 lines) as a quick type-check sanity check - SessionStart: Shows
git status --shortand last 3 commits - Plugin:
pyright-lspenabled for real-time type checking
/verify- Run all 7 quality checks (ruff, flake8, mypy, pyright, ty, pyrefly, coverage)/test- Run unit tests with coverage/type-check- Run all 4 type checkers- Use
/clearbetween unrelated features;/compactif context feels bloated