# Contributing to PyFortis

Thanks for your interest in contributing. This document covers setup, code quality, and how to publish releases.

## Setup

1. Clone the repository and enter the project root.
2. Create a virtual environment and install the package in editable mode with dev dependencies:

   ```bash
   pip install -e ".[dev]"
   ```

   Or with uv:

   ```bash
   uv pip install -e ".[dev]"
   ```

## Code quality

Before opening a PR, run:

| Command | Purpose |
| --------| --------|
| `ruff check src tests` | Lint |
| `ruff format src tests` | Format |
| `mypy src` | Type check |
| `pytest` | Tests |
| `pytest --cov=pyfortis` | Tests with coverage (optional) |

Conventions:

- The project uses **Ruff** for linting and formatting (see `[tool.ruff]` in `pyproject.toml`).
- **mypy** runs in strict mode; keep type hints on public API and new code.
- Add docstrings for public modules, classes, and functions.

## Pull requests

- Branch from `main` (or the default branch).
- Ensure all of the above checks pass.
- Keep PRs focused; reference any related issues.

## Publishing

Releases are published to [PyPI](https://pypi.org/project/pyfortis/). Maintainers use the Makefile at the project root.

1. **Bump version** in `pyproject.toml` (e.g. `0.1.0` → `0.1.1`). PyPI does not allow re-uploading the same version.
2. **Update CHANGELOG.md**: Move "Unreleased" items under the new version and add a new "Unreleased" section.
3. **Try Test PyPI first** (recommended):

   ```bash
   make publish-test
   ```

   This builds the package and uploads to [Test PyPI](https://test.pypi.org/). You will be prompted for your Test PyPI username and password (use an API token as the password). Install from Test PyPI to verify:

   ```bash
   pip install --index-url https://test.pypi.org/simple/ pyfortis
   ```

4. **Publish to production PyPI**:

   ```bash
   make publish
   ```

   You will be prompted for your PyPI username and password (use a PyPI API token as the password, not your account password).

The `.[dev]` install includes `build` and `twine`. The Makefile’s `build` target runs `python -m build`; `publish` and `publish-test` depend on it and upload the contents of `dist/`.
