chore: bring codebase to 100% clean mypy compliance across core modules#644
Open
mishrak5j wants to merge 3 commits into
Open
chore: bring codebase to 100% clean mypy compliance across core modules#644mishrak5j wants to merge 3 commits into
mishrak5j wants to merge 3 commits into
Conversation
…tion, and strip dead ignore
…p dead code signatures
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
This PR appears to modernize typing and runtime compatibility by removing legacy import fallbacks, tightening type annotations, and clarifying request payload handling (especially for gzip).
Changes:
- Simplifies Python imports by removing Python 2-era fallbacks (
queue,urllib.parse). - Improves typing clarity in client/consumer logic and request payload handling.
- Removes a couple of
type: ignoreannotations around imports and conversions.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| posthog/request.py | Types path, introduces payload variable for gzip/non-gzip request bodies, updates adapter import typing. |
| posthog/feature_flags.py | Removes type: ignore around float(value) conversion. |
| posthog/consumer.py | Removes Python 2 fallback import; adjusts retryability logic to check exc.status type-safely. |
| posthog/client.py | Removes Python 2 fallbacks; imports Queue/Full directly and adds type annotations for queue and flag caches. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Contributor
|
Reviews (1): Last reviewed commit: "fix(client, flags): handle optional befo..." | Re-trigger Greptile |
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
This change resolves 15 static type-checking failures flagged by
mypyacross the core SDK modules (client.py,request.py,consumer.py, andfeature_flags.py).Key Improvements:
import Queue as queue,from urlparse import ...) that were triggering module redefinition collisions ([no-redef]).consumer.py's retry math blocks.str | bytespayload union variables instead of reusing variables dynamically.str + None) and wrapped optional instance fields (before_send,_feature_flags,feature_flags_by_key) in strictOptional[...]layout signatures to accommodate null-state initializations.💚 How did you test it?
Verified the architectural layout updates locally using the primary static validation check engine: