Skip to content

Conversation

@sjsadowski
Copy link

Summary

Python worker examples used dot notation for json objects converted to dicts, which doesn't work out of the box. In order to keep the examples simple, changed dot notation to key notation. Also removed string concatenation using plus signs and string.format() to both be f-strings as the current releases of pyodide all target support for python > 3.6

Documentation checklist

1. updated from string.format() to f-strings (supported since python 3.6)
2. Updated examples to be internally consistent: the params example was referencing the dict element directly whereas the json example was setting a variable from the dict 
3. Updated json example to fix dicts in python do not use dot notation and reference the key instead.
correct spacing for new line int parameters example
1. in hello function, update to use f-string for return instead of concatenating strings with plus symbol
2. in POST example, fix dict reference to use key as dicts do not support dot notation by default
@hyperlint-ai
Copy link
Contributor

hyperlint-ai bot commented Jul 16, 2025

Howdy and thanks for contributing to our repo. The Cloudflare team reviews new, external PRs within two (2) weeks. If it's been two weeks or longer without any movement, please tag the PR Assignees in a comment.

We review internal PRs within 1 week. If it's something urgent or has been sitting without a comment, start a thread in the Developer Docs space internally.


PR Change Summary

Updated Python worker documentation to improve code examples and ensure compatibility with Python 3.6 and above.

  • Changed dot notation to key notation for JSON objects in examples.
  • Replaced string concatenation with f-strings for better readability and performance.
  • Ensured all examples are compatible with Python versions greater than 3.6.

Modified Files

  • src/content/docs/workers/languages/python/examples.mdx
  • src/content/docs/workers/languages/python/index.mdx

How can I customize these reviews?

Check out the Hyperlint AI Reviewer docs for more information on how to customize the review.

If you just want to ignore it on this PR, you can add the hyperlint-ignore label to the PR. Future changes won't trigger a Hyperlint review.

Note specifically for link checks, we only check the first 30 links in a file and we cache the results for several hours (for instance, if you just added a page, you might experience this). Our recommendation is to add hyperlint-ignore to the PR to ignore the link check for this PR.

@github-actions github-actions bot added size/s product:workers Related to Workers product labels Jul 16, 2025
@sjsadowski
Copy link
Author

closing this PR, may reopen - I have now been using python workers in two different setups and I'm getting inconsistent results with the dot notation; on one machine running under wrangler dev (await request.json)["key"] works and on another it does not, but the documented (await request.json()).key works. Will open a new request once this is resolved with the correct updates.

@sjsadowski sjsadowski closed this Jul 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

product:workers Related to Workers product size/s

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants