Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vyper/ast/annotation.py putting out deprecation warning for ast.Str and n #4051

Closed
0xMaka opened this issue May 25, 2024 · 2 comments
Closed

Comments

@0xMaka
Copy link
Contributor

0xMaka commented May 25, 2024

Version Information

  • vyper Version (output of vyper --version) : 0.3.10+commit.9136169
  • OS : Linux 6.8.8-arch1-1x86_64 GNU/Linux
  • Python Version (output of python --version) : Python 3.12.3

What's your issue about?

Deprecation warnings post 3.12

Please include information like:

  • full output of the error you received
/home/maka/w3/shai/env/lib/python3.12/site-packages/vyper/ast/annotation.py:77: DeprecationWarning: ast.Str is deprecated and will be removed in Python 3.14; use ast.Constant instead
  if isinstance(n, python_ast.Expr) and isinstance(n.value, python_ast.Str):
/home/maka/w3/shai/env/lib/python3.12/site-packages/vyper/ast/annotation.py:213: DeprecationWarning: Attribute n is deprecated and will be removed in Python 3.14; use value instead
  elif isinstance(node.n, float):
/home/maka/w3/shai/env/lib/python3.12/site-packages/vyper/ast/annotation.py:217: DeprecationWarning: Attribute n is deprecated and will be removed in Python 3.14; use value instead
  elif isinstance(node.n, int):
# repeated.
  • what command you ran
vyper test.vy
vyper test.vy -f abi
  • the code that caused the failure:

Minimal reproduceable:

# @pragma version ^0.3.10
MAX : constant(uint256)                           =  100

@external
@view
def test(_xs : DynArray[uint256, MAX]) -> (DynArray[uint256, MAX]):
  return _xs

A simple passing function without args, was not sufficient.

  • please try running your example with the --verbose flag turned on
    cli specified: Settings(compiler_version=None, optimize=None, evm_version=None) # rest is as above

How can it be fixed?

Updating those lines in vyper/ast/annotation.py as outlined in the error as well as referenced here:

Replacing:
python_ast.Str with python_ast.Constant && (node.n, int)/(node.n, float) with (node.value, int)/(node.value, float)

Seems to silence warnings while giving desired results.

@charles-cooper
Copy link
Member

i believe this was addressed in ef2d535 (#3998), @0xMaka are you still seeing this as of v0.4.0rc5?

@0xMaka
Copy link
Contributor Author

0xMaka commented May 25, 2024

@charles-cooper Updating to the pre release solves this. Please excuse having missed that.
Closing, cheers.

@0xMaka 0xMaka closed this as completed May 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants