diff --git a/refactor/ast.py b/refactor/ast.py index 3d23262..be90edb 100644 --- a/refactor/ast.py +++ b/refactor/ast.py @@ -107,7 +107,14 @@ def unparse(self, node: ast.AST) -> str: ... # pragma: no cover -class BaseUnparser(ast._Unparser): # type: ignore +try: + _UnparserBase = ast._Unparser +except AttributeError: + # Python 3.14+: _Unparser moved to C extension module + from _ast_unparse import Unparser as _UnparserBase # type: ignore[import-not-found] + + +class BaseUnparser(_UnparserBase): # type: ignore """A public :py:class:`ast._Unparser` API that can be used to customize the AST re-synthesis process."""