Title: Add more granularity to _pyrepl syntax theming for "keywords" · Issue #134953 · python/cpython · GitHub
Open Graph Title: Add more granularity to _pyrepl syntax theming for "keywords" · Issue #134953 · python/cpython
X Title: Add more granularity to _pyrepl syntax theming for "keywords" · Issue #134953 · python/cpython
Description: Feature or enhancement Proposal: I made a custom _colorize theme to try making my REPL syntax highlighting look similar to my text editor's. This is the theme I used: theme_with_dim_operators = default_theme.copy_with( syntax=Syntax( key...
Open Graph Description: Feature or enhancement Proposal: I made a custom _colorize theme to try making my REPL syntax highlighting look similar to my text editor's. This is the theme I used: theme_with_dim_operators = def...
X Description: Feature or enhancement Proposal: I made a custom _colorize theme to try making my REPL syntax highlighting look similar to my text editor's. This is the theme I used: theme_with_dim_operators =...
Opengraph URL: https://github.com/python/cpython/issues/134953
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Add more granularity to _pyrepl syntax theming for \"keywords\"","articleBody":"# Feature or enhancement\n\n### Proposal:\n\nI made a custom `_colorize` theme to try making my REPL syntax highlighting look similar to my text editor's.\n\nThis is the theme I used:\n\n```python\ntheme_with_dim_operators = default_theme.copy_with(\n syntax=Syntax(\n keyword=ANSIColors.GREEN,\n builtin=ANSIColors.BLUE,\n comment=ANSIColors.INTENSE_YELLOW,\n string=ANSIColors.CYAN,\n number=ANSIColors.CYAN,\n definition=ANSIColors.BLUE,\n soft_keyword=ANSIColors.BOLD_GREEN,\n ),\n)\n```\n\nI then used this example code to check the highlighting between the two: \n\n```python\nfrom math import pi\nprint(f\"Welcome to Python {pi:.2f}\")\nname = None\nif name is None:\n print(\"It's\", True)\n```\n\nPasting that code in my text editor (vim), looks like this:\n\n\n\nPasting the same code in the REPL, looks like this:\n\n\n\nThe granularity with syntax highlighting needs to stop *somewhere*, but I feel it would be nice to add a bit more granularity than is currently supported by `_colorize`.\n\nIn particular, it would be nice to distinguish between:\n\n1. Syntax keywords in general (`if`, `is`, `def`, `for`, `with`, etc.)\n2. Keywords that are variables (`True`, `False`, `None`)\n3. Imports in particular (`from`, `import`)\n\nI feel that distinguishing between 1 and 2 is more important than between 1 and 3. While `None` *is* a keyword, seeing it appear in the same color as `is` and other keywords feels odd.\n\n### Has this already been discussed elsewhere?\n\nThis is a minor feature, which does not need previous discussion elsewhere\n\n### Links to previous discussion of this feature:\n\n_No response_\n\n\u003c!-- gh-linked-prs --\u003e\n### Linked PRs\n* gh-135000\n* gh-138928\n* gh-138931\n* gh-138939\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/treyhunner","@type":"Person","name":"treyhunner"},"datePublished":"2025-05-30T22:54:21.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":4},"url":"https://github.com/134953/cpython/issues/134953"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:2b043a1b-f252-a789-0a3e-41554ede2332 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A61C:12343F:11CD530:17D9D4B:696AD17F |
| html-safe-nonce | abf78bcc1acee4f99e291884afc869c4bb335320da9604fe86ea040f635ee598 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBNjFDOjEyMzQzRjoxMUNENTMwOjE3RDlENEI6Njk2QUQxN0YiLCJ2aXNpdG9yX2lkIjoiNTI4NzYyNTY3MTEzODAwNTM3NSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | e559ec2e77a40b6893305d3eaff65371782cdc95318cb856e41a19dc07f2718a |
| hovercard-subject-tag | issue:3104424720 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/134953/issue_layout |
| twitter:image | https://opengraph.githubassets.com/cc702c925877aaba9516c8692d5216c529c0bd73567b4739a7bec12549946cc3/python/cpython/issues/134953 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/cc702c925877aaba9516c8692d5216c529c0bd73567b4739a7bec12549946cc3/python/cpython/issues/134953 |
| og:image:alt | Feature or enhancement Proposal: I made a custom _colorize theme to try making my REPL syntax highlighting look similar to my text editor's. This is the theme I used: theme_with_dim_operators = def... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | treyhunner |
| hostname | github.com |
| expected-hostname | github.com |
| None | c785f4ce187e9e7331257791b36ddee01625bb8e292a9b4fe2c16d4c006abf5d |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | c718a376fcf780eb22089171adb84a543f660bf7 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width