feat: automatically update pre-commit config with posthog package for Python projects#266
feat: automatically update pre-commit config with posthog package for Python projects#266rnegron wants to merge 4 commits intoPostHog:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a new wizard step to automatically update an existing pre-commit configuration for Python projects so type-checking hooks include the posthog package in additional_dependencies, preventing mypy/pyright/pytype failures after installing PostHog.
Changes:
- Added
updatePreCommitConfigStepto parse.pre-commit-config.(yml|yaml)and appendposthogto relevant hooks’additional_dependencies. - Wired the new step into the agent runner for Python integrations (Django/Flask/FastAPI/Python) and reflected it in the wizard outro.
- Added Jest test coverage and introduced the
yamldependency.
Reviewed changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/steps/update-pre-commit-config.ts | Implements YAML parsing + mutation of pre-commit config to add posthog to type-checking hooks. |
| src/steps/index.ts | Exports the new step from the steps barrel. |
| src/steps/tests/update-pre-commit-config.test.ts | Tests config discovery, idempotency, formatting preservation, and error paths. |
| src/lib/agent-runner.ts | Runs the new step for Python integrations and includes it in the outro changes list. |
| package.json | Adds yaml as a direct dependency. |
| pnpm-lock.yaml | Locks the new yaml dependency/version. |
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
by the way, I am aware there is some ongoing work around how the wizard handles I think |
Summary
.pre-commit-config.yaml(if available) to include theposthogPython package inadditional_dependencies(for type-checking hooks, i.e mypy, pyright, pytype).Background
I ran the PostHog wizard on a local Django project and everything worked great! Except that my
pre-commitmypy hook failed... Adding this step to hopefully solve for anyone else that might run into this in the future!Test plan
pnpm link --globalin this repo and thenwizard --region usin the local Django project.Here is a snippet of final
wizardoutput (see last point):