GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-140764: Improve syntax warning hint for missing commas by ayushm98 · Pull Request #143278 · python/cpython

Conversation

@ayushm98

@ayushm98 ayushm98 commented Dec 29, 2025 •
edited by bedevere-app Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Fixes #140764

Summary

Makes the syntax warning hint clearer when detecting potentially missing commas in sequence literals.

Problem

Current warning: 'int' object is not subscriptable; perhaps you missed a comma?

This hint can be cryptic - it's not immediately obvious that it's suggesting the code might have been meant as separate items in a sequence.

Solution

New warning: 'int' object is not subscriptable; did you miss a comma to separate sequence elements?

Example

# Before:
>>> lambda: 1[2]
<input>:1: SyntaxWarning: 'int' object is not subscriptable; perhaps you missed a comma?

# After:
>>> lambda: 1[2]
<input>:1: SyntaxWarning: 'int' object is not subscriptable; did you miss a comma to separate sequence elements?

Much clearer what the intended fix might be!

Changes

  • Updated 3 warning messages in Python/codegen.c:
    • Callable check
    • Subscriptable check
    • Index type check
  • Updated corresponding test regex patterns in Lib/test/test_grammar.py

Test Plan

  • All existing tests updated to match new message
  • Warning still triggers in same cases, just with clearer text
  • No behavioral changes, only message improvement
  • Issue: Make "perhaps you missed a comma?" hint in syntax warnings less cryptic #140764

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@ayushm98
Improve syntax warning hint for missing commas
4f4e72f
Fixes python#140764

Changed the cryptic 'perhaps you missed a comma?' hint to the
clearer 'did you miss a comma to separate sequence elements?'

This makes the warning's intention more obvious when code like
`[]()`, `1[2]`, or `[][]  ` triggers a syntax warning.

Updated error messages in Python/codegen.c for:
- callable check
- subscriptable check
- index type check

Updated corresponding tests in Lib/test/test_grammar.py to match
the new warning text.
@ayushm98
ayushm98 requested review from iritkatriel and markshannon as code owners December 29, 2025 23:28
@python-cla-bot

python-cla-bot Bot commented Dec 29, 2025

Copy link
Copy Markdown

The following commit authors need to sign the Contributor License Agreement:

  • [email protected]

CLA not signed

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app

bedevere-app Bot commented Dec 29, 2025

Copy link
Copy Markdown

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot added the awaiting review label Dec 29, 2025
@StanFromIreland StanFromIreland changed the title Improve syntax warning hint for missing commas gh-140764: Improve syntax warning hint for missing commas Dec 30, 2025
@bedevere-app bedevere-app Bot mentioned this pull request Dec 30, 2025
Make "perhaps you missed a comma?" hint in syntax warnings less cryptic #140764
Open
@StanFromIreland
StanFromIreland requested a review from ncoghlan December 30, 2025 09:04
@StanFromIreland

StanFromIreland commented Dec 30, 2025

Copy link
Copy Markdown
Member

We already have #140893 open?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@picnixz

picnixz commented Dec 30, 2025

Copy link
Copy Markdown
Member

Please don't open PRs when there is already one: #140893.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@picnixz picnixz closed this Dec 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@markshannon markshannon Awaiting requested review from markshannon markshannon is a code owner
@iritkatriel iritkatriel Awaiting requested review from iritkatriel iritkatriel is a code owner
@ncoghlan ncoghlan Awaiting requested review from ncoghlan

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

awaiting review

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Make "perhaps you missed a comma?" hint in syntax warnings less cryptic

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@ayushm98 @StanFromIreland @picnixz
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.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.