Skip to content

gh-149267: Document ast.Constant.kind attribute#149268

Merged
JelleZijlstra merged 2 commits intopython:mainfrom
anujbharambe:doc-ast-constant-kind
May 2, 2026
Merged

gh-149267: Document ast.Constant.kind attribute#149268
JelleZijlstra merged 2 commits intopython:mainfrom
anujbharambe:doc-ast-constant-kind

Conversation

@anujbharambe
Copy link
Copy Markdown
Contributor

@anujbharambe anujbharambe commented May 2, 2026

Summary

  • Add kind to the Constant class signature in Doc/library/ast.rst
  • Document that kind is 'u' for u-prefixed string literals and None for all other constants
  • Add a doctest showing the kind='u' output

Fixes #149267

CC- @JelleZijlstra

The kind attribute of ast.Constant was not mentioned in the
documentation. It is set to 'u' for u-prefixed string literals
and None for all other constants.
@read-the-docs-community
Copy link
Copy Markdown

read-the-docs-community Bot commented May 2, 2026

Documentation build overview

📚 cpython-previews | 🛠️ Build #32507759 | 📁 Comparing db06995 against main (bb5e41e)

  🔍 Preview build  

2 files changed
± download.html
± library/ast.html

Comment thread Doc/library/ast.rst Outdated
and the constants :data:`None` and :data:`Ellipsis`.

The ``kind`` attribute is an optional string. For string literals with a
``u`` prefix (e.g. ``u'hello'``), ``kind`` is set to ``'u'``. For all other
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
``u`` prefix (e.g. ``u'hello'``), ``kind`` is set to ``'u'``. For all other
``u`` prefix, ``kind`` is set to ``'u'``. For all other

Per the style guide, please don't use latin abbreviations. Furthermore, I don't think the example is necessary here.

@JelleZijlstra JelleZijlstra added needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes labels May 2, 2026
Copy link
Copy Markdown
Member

@JelleZijlstra JelleZijlstra left a comment

Choose a reason for hiding this comment

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

Thank you!

@JelleZijlstra JelleZijlstra merged commit 3a1df78 into python:main May 2, 2026
38 checks passed
@miss-islington-app
Copy link
Copy Markdown

Thanks @anujbharambe for the PR, and @JelleZijlstra for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14.
🐍🍒⛏🤖

@github-project-automation github-project-automation Bot moved this from Todo to Done in Docs PRs May 2, 2026
@bedevere-app
Copy link
Copy Markdown

bedevere-app Bot commented May 2, 2026

GH-149293 is a backport of this pull request to the 3.14 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.14 bugs and security fixes label May 2, 2026
@bedevere-app
Copy link
Copy Markdown

bedevere-app Bot commented May 2, 2026

GH-149294 is a backport of this pull request to the 3.13 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.13 bugs and security fixes label May 2, 2026
JelleZijlstra pushed a commit that referenced this pull request May 2, 2026
…149294)

gh-149267: Document ast.Constant.kind attribute (GH-149268)

The kind attribute of ast.Constant was not mentioned in the
documentation. It is set to 'u' for u-prefixed string literals
and None for all other constants.

---------
(cherry picked from commit 3a1df78)

Co-authored-by: Anuj Nitin Bharambe <119653366+anujbharambe@users.noreply.github.com>
Co-authored-by: Anuj Bharambe <anujnitinb@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Documentation in the Doc dir skip news

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

ast.Constant.kind is undocumented

4 participants