Skip to content

Conversation

@jodal
Copy link
Contributor

@jodal jodal commented Oct 30, 2025

This fixes a SyntaxWarning on Python 3.14.

❯ uvx --no-cache --python 3.14.0 --with posthog==6.7.11 python -c "import posthog"
Installed 11 packages in 5ms
.../lib/python3.14/site-packages/posthog/consumer.py:92: SyntaxWarning: 'return' in a 'finally' block
  return success

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

1 file reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

@jodal jodal force-pushed the fix-syntax-warning branch from 9d2e454 to 1d8b0f1 Compare November 6, 2025 21:50
@jodal jodal changed the title fix: Avoid return from finally: block Avoid return from finally block to fix Python 3.14 SyntaxWarning Nov 13, 2025
@pauldambra pauldambra requested a review from Copilot January 7, 2026 20:52
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a SyntaxWarning that occurs when running the posthog library on Python 3.14 by moving a return statement from inside a finally block to outside of it.

Key Changes:

  • Moved the return success statement from inside the finally block to after it in the upload() method

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Member

@pauldambra pauldambra left a comment

Choose a reason for hiding this comment

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

let's at least wait until #403 is merged

i want to be sure we don't break one thing while fixing another

when #403 is merged can you update this PR

@jodal jodal force-pushed the fix-syntax-warning branch from 1d8b0f1 to 8ac3073 Compare January 7, 2026 22:36
@jodal
Copy link
Contributor Author

jodal commented Jan 7, 2026

I've rebased the PR and made it log and swallow any errors from the on_error handler to keep the old behavior where the return in the finally clause implicitly swallowed any errors in the except block.

Copy link
Member

@pauldambra pauldambra left a comment

Choose a reason for hiding this comment

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

the log is a good touch for a previously totally silent error 👍

@pauldambra pauldambra changed the title Avoid return from finally block to fix Python 3.14 SyntaxWarning fix: avoid return from finally block to fix Python 3.14 SyntaxWarning Jan 7, 2026
@pauldambra
Copy link
Member

@Piccirello i can't merge here because

Merging is blocked
Code scanning is waiting for results from CodeQL for the commits db70702 or ae32dfc.

i'm guessing that's because it's external?

you-are-our-only-hope.meme

@Piccirello
Copy link
Contributor

CodeQL requires you to setup CodeQL Advanced in a repo in order to run it against external contributor PRs (super annoying). We've started setting this up in repos as it pops up, like in posthog, posthog-android, posthog-ios. #405 should fix this.

@rafaeelaudibert
Copy link
Member

@jodal, I've merged @Piccirello's #405, but we now need you to merge your branch with the current master to get CodeQL to run. Do you mind doing that?

@pauldambra
Copy link
Member

one more ping, i can't figure out how to update this to master myself, sorry!
if you can bring this up-to-date, codeql should run and we're good to rock and roll

jodal and others added 2 commits January 8, 2026 15:28
This fixes a SyntaxWarning on Python 3.14.

```
❯ uvx --no-cache --python 3.14.0 --with posthog==6.7.11 python -c "import posthog"
Installed 11 packages in 5ms
.../lib/python3.14/site-packages/posthog/consumer.py:92: SyntaxWarning: 'return' in a 'finally' block
  return success
````
@jodal jodal force-pushed the fix-syntax-warning branch from ae32dfc to 9ec7ca7 Compare January 8, 2026 14:29
@jodal
Copy link
Contributor Author

jodal commented Jan 8, 2026

Rebased again.

@Piccirello
Copy link
Contributor

Piccirello commented Jan 8, 2026

I've enabled the repo setting "Always suggest updating pull request branches", which will now show the “update branch” option.

@pauldambra pauldambra merged commit f9c2959 into PostHog:master Jan 8, 2026
14 of 15 checks passed
@jodal jodal deleted the fix-syntax-warning branch January 8, 2026 22:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants