Skip to content

Python 3.14: AttributeError: module 'ast' has no attribute '_Unparser' #91

@hugovk

Description

@hugovk

refactor no longer works on Python 3.14:

Python 3.14.0 (v3.14.0:ebf955df7a8, Oct  7 2025, 08:20:14) [Clang 16.0.0 (clang-1600.0.26.6)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import refactor
Traceback (most recent call last):
  File "<python-input-0>", line 1, in <module>
    import refactor
  File "/private/tmp/refactor/refactor/__init__.py", line 4, in <module>
    from refactor.actions import *
  File "/private/tmp/refactor/refactor/actions.py", line 9, in <module>
    from refactor.ast import split_lines
  File "/private/tmp/refactor/refactor/ast.py", line 110, in <module>
    class BaseUnparser(ast._Unparser):  # type: ignore
                       ^^^^^^^^^^^^^
AttributeError: module 'ast' has no attribute '_Unparser'. Did you mean: 'unparse'?

3.13 is okay:

Python 3.13.9 (v3.13.9:8183fa5e3f7, Oct 14 2025, 10:27:13) [Clang 16.0.0 (clang-1600.0.26.6)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import refactor
>>>

This also prevents tools such as https://github.com/isidentical/teyit from running on Python 3.14.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions