FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Deprecate creation of abstract AST nodes · Issue #116021 · python/cpython · GitHub

Repository navigation

Deprecate creation of abstract AST nodes #116021

Closed

Description

Feature or enhancement

Proposal:

Currently all of these are allowed:

>>> import ast
>>> ast.expr()
<ast.expr object at 0x10526cce0>
>>> ast.stmt()
<ast.stmt object at 0x1054508d0>
>>> ast.AST()
<ast.AST object at 0x105229610>

But these are meant to be abstract classes; constructing them is not meaningful. I propose to raise a DeprecationWarning when they are constructed and raise an error a few versions down.

(Originally suggested by Cornelius Krupp on discuss.python.)

Has this already been discussed elsewhere?

I have already discussed this feature proposal on Discourse

Links to previous discussion of this feature:

https://discuss.python.org/t/proposed-change-to-ast-node-constructors/46531/4

Linked PRs

Activity

  1. bzoracler commented on Feb 28, 2024

    Contributor

    Since there are no current and planned restrictions on subclassing these abstract nodes, I have a gut feeling that deprecating this behaviour will affect code which subclass these abstract nodes and which implicitly or explicitly call the superclass constructor.

    Projects which rely on AST enrichment pipelines (linters, code generators, Python-like language extensions, etc.) may rely on the current behaviour.

  2. added a commit that references this issue on Sep 14, 2025
  3. added a commit that references this issue on Oct 13, 2025
  4. added a commit that references this issue on Nov 22, 2025
  5. added a commit that references this issue on Apr 28, 2026
  6. added a commit that references this issue on May 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibStandard Library Python modules in the Lib/ directorytopic-parsertype-featureA feature request or enhancement

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL