Skip to content

Add conformance tests to allow soft keywords in as namedtuple fields - #2399

Open
quag wants to merge 1 commit into
python:mainfrom
quag:main
Open

quag wants to merge 1 commit into
python:mainfrom
quag:main

Conversation

@quag

@quag quag commented Dec 4, 2026

Copy link
Copy Markdown

The zuban v0.11.1 type checker had a bug where it disallowed soft keywords ("match", "case", and "type") to be field names of namedtuples. namedtuple fields must be valid python identifiers that do not start with a "_". Soft keywords are valid python identifiers. This bug will be fixed in the next version of Zuban. This commit adds conformance tests for both allowing soft keywords as namedtuple fields and disallowing hard keywords.

The other type checkers all correctly allowed soft keywords and disallowed hard keywords.

https://docs.python.org/3/reference/lexical_analysis.html#keywords
https://docs.python.org/3/reference/lexical_analysis.html#soft-keywords
https://docs.python.org/3/library/keyword.html

@python-cla-bot

python-cla-bot Bot commented Dec 4, 2026 •

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.

CLA signed

@quag quag changed the title Add conformance tests to allow soft keywords in as namedtuple fields and disallow hard keywords Add conformance tests to allow soft keywords in as namedtuple fields Dec 5, 2026


softkw = SoftKeywords(match=1, case=2, type=3, lazy=4)
softkw.match # OK

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Personally I would like a assert_type(softkw.match, int) here and in the cases in the other file.

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.

3 participants