Skip to content
Merged
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
35 changes: 13 additions & 22 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,35 +6,26 @@ Thanks for your interest in improving the PostHog Python SDK.

This repo requires all commits to be signed. To configure commit signing, see the [PostHog handbook](https://posthog.com/handbook/engineering/security#commit-signing).

## Testing locally
## Setup

We recommend using [uv](https://docs.astral.sh/uv/).

1. Create a virtual environment:
- `uv venv env`
- or `python3 -m venv env`
2. Activate it:
- `source env/bin/activate`
3. Install the package in editable mode with development and test dependencies:
- `uv sync --extra dev --extra test`
- or `pip install -e ".[dev,test]"`
4. Install pre-commit hooks:
- `pre-commit install`
5. Run the test suite:
- `make test`
6. Run a specific test if needed:
- `pytest -k test_no_api_key`

## Recommended `uv` workflow

```bash
uv python install 3.12
uv python pin 3.12
uv venv
source .venv/bin/activate
uv sync --extra dev --extra test
pre-commit install
make test
```

## CI-aligned checks

Run the same core checks CI uses before opening a PR:

```bash
ruff format --check .
ruff check .
mypy --no-site-packages --config-file mypy.ini . | mypy-baseline filter
pytest --verbose --timeout=30
python -W error -c "import posthog"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Import check environment differs from CI

CI's import-check job runs pip install . (no extras) before python -W error -c "import posthog", specifically to verify the base package imports cleanly with only its required dependencies. Locally, this runs against the full --extra dev --extra test environment (which includes openai, anthropic, langchain, etc.), so any warning that only surfaces in a minimal-install environment would not be reproduced.

A closer local equivalent would be:

uv run --no-dev --no-extra dev --no-extra test python -W error -c "import posthog"

or simply pip install . && python -W error -c "import posthog" in a fresh venv.

Prompt To Fix With AI
This is a comment left during a code review.
Path: CONTRIBUTING.md
Line: 28

Comment:
**Import check environment differs from CI**

CI's `import-check` job runs `pip install .` (no extras) before `python -W error -c "import posthog"`, specifically to verify the base package imports cleanly with only its required dependencies. Locally, this runs against the full `--extra dev --extra test` environment (which includes `openai`, `anthropic`, `langchain`, etc.), so any warning that only surfaces in a minimal-install environment would not be reproduced.

A closer local equivalent would be:

```bash
uv run --no-dev --no-extra dev --no-extra test python -W error -c "import posthog"
```

or simply `pip install . && python -W error -c "import posthog"` in a fresh venv.

How can I resolve this? If you propose a fix, please make it concise.

```

## Running locally
Expand Down
Loading