fix: no-op global client for blank api key#632
Merged
Conversation
Contributor
Prompt To Fix All With AIFix the following 1 code review issue. Work through them one at a time, proposing concise fixes.
---
### Issue 1 of 1
posthog/__init__.py:1066-1072
The blank-key note is floating between the `Returns:` section and `Category:` as an unanchored paragraph, which looks out of place in Google-style docstrings and may render oddly in generated docs. Folding it into the `Returns:` description keeps all return-value semantics in one place.
```suggestion
Returns:
The global ``Client`` instance. If ``api_key`` is missing or blank,
the client is disabled and module-level calls become no-ops.
Category:
```
Reviews (1): Last reviewed commit: "chore: add changeset for blank api key n..." | Re-trigger Greptile |
Contributor
posthog-python Compliance ReportDate: 2026-05-28 14:00:01 UTC ✅ All Tests Passed!45/45 tests passed Capture Tests✅ 29/29 tests passed View Details
Feature_Flags Tests✅ 16/16 tests passed View Details
|
ioannisj
approved these changes
May 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
💡 Motivation and Context
Module-level setup should be safe when the global API key is unset or blank. Instead of raising during setup, blank API keys now create a disabled no-op global client so module-level calls are ignored consistently.
Changes:
💚 How did you test it?
.venv/bin/python -m pytest posthog/test/test_module.py -q📝 Checklist
If releasing new changes
sampo addto generate a changeset file