From 3dbb5993baa1856d468029f0f38d5f91c054d73b Mon Sep 17 00:00:00 2001 From: Mia Miu Date: Tue, 2 Jun 2026 00:07:53 +1200 Subject: [PATCH] fix: add missing return type annotations --- posthog/__init__.py | 8 ++++---- posthog/client.py | 9 +++++---- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/posthog/__init__.py b/posthog/__init__.py index 559aba88..2e383f15 100644 --- a/posthog/__init__.py +++ b/posthog/__init__.py @@ -561,7 +561,7 @@ def alias( def capture_exception( exception: Optional[ExceptionArg] = None, **kwargs: Unpack[OptionalCaptureArgs], -): +) -> Optional[str]: """ Capture exceptions that happen in your code. @@ -1006,7 +1006,7 @@ def load_feature_flags(): return _proxy("load_feature_flags") -def flush(): +def flush() -> None: """ Tell the client to flush all queued events. @@ -1022,7 +1022,7 @@ def flush(): _proxy("flush") -def join(): +def join() -> None: """ Block program until the client clears the queue. Used during program shutdown. You should use `shutdown()` directly in most cases. @@ -1038,7 +1038,7 @@ def join(): _proxy("join") -def shutdown(): +def shutdown() -> None: """ Flush all messages and cleanly shutdown the client. diff --git a/posthog/client.py b/posthog/client.py index 5a3bd85a..712cefcf 100644 --- a/posthog/client.py +++ b/posthog/client.py @@ -1074,7 +1074,7 @@ def capture_exception( self, exception: Optional[ExceptionArg], **kwargs: Unpack[OptionalCaptureArgs], - ): + ) -> Optional[str]: """ Capture an exception for error tracking. @@ -1196,6 +1196,7 @@ def capture_exception( return res except Exception as e: self.log.exception(f"Failed to capture exception: {e}") + return None @staticmethod def _reinit_after_fork_weak(weak_self): @@ -1346,7 +1347,7 @@ def _enqueue(self, msg, disable_geoip): self.log.warning("analytics-python queue is full") return None - def flush(self): + def flush(self) -> None: """ Force a flush from the internal queue to the server. Do not use directly, call `shutdown()` instead. @@ -1362,7 +1363,7 @@ def flush(self): # Note that this message may not be precise, because of threading. self.log.debug("successfully flushed about %s items.", size) - def join(self): + def join(self) -> None: """ End the consumer thread once the queue is empty. Do not use directly, call `shutdown()` instead. @@ -1386,7 +1387,7 @@ def join(self): # Shutdown the cache provider (release locks, cleanup) self._shutdown_flag_definition_cache_provider() - def shutdown(self): + def shutdown(self) -> None: """ Flush all messages and cleanly shutdown the client. Call this before the process ends in serverless environments to avoid data loss.