ikamensh / flynt

A tool to automatically convert old string literal formatting to f-strings
MIT License
689 stars 33 forks source link

Python AST deprecations #195

Open akaihola opened 8 months ago

akaihola commented 8 months ago

In my CI build, I'm getting these deprecation warnings from Python 3.12:

  lib/python3.12/site-packages/astor/op_util.py:92: DeprecationWarning:
    ast.Num is deprecated and will be removed in Python 3.14; use ast.Constant instead
    precedence_data = dict((getattr(ast, x, None), z) for x, y, z in op_data)
  lib/python3.12/site-packages/flynt/utils/utils.py:74: DeprecationWarning:
    ast.Str is deprecated and will be removed in Python 3.14; use ast.Constant instead
    ) -> Union[ast.FormattedValue, ast.Str]:
  lib/python3.12/site-packages/flynt/transform/format_call_transforms.py:22: DeprecationWarning:
    Attribute s is deprecated and will be removed in Python 3.14; use value instead
    string = fmt_call.func.value.s
  lib/python3.12/ast.py:407: DeprecationWarning:
    visit_Str is deprecated; add visit_Constant
    return visitor(node)
ikamensh commented 3 months ago

Thanks for reporting! hm, it seems ast.Str and ast.Num and perhaps other nodes will be all merged into ast.Constant. Naively replacing ast.Str with ast.Constant leads to errors in flynt.

Unfortunately I couldn't find a solution to suppress these warnings either, they are no issue for users until they start using python3.14, so if I could I'd just supress warnings until then.