zksync-sdk / zksync-python

Python 3.8 SDK for zkSync
MIT License
116 stars 65 forks source link

importing library fails. pydantic.errors.PydanticUserError: Field 'decimals' defined on a base class was overridden by a non-annotated attribute #57

Open pedrodparkes opened 1 year ago

pedrodparkes commented 1 year ago

tested on Py 3.8, 3.9 in docker containers: python:3.8-slim python:3.8-bullseye python:3.9-alpine3.17 and later py versions.

`#0 1.888 Traceback (most recent call last):

0 1.888 File "/main.py", line 1, in

0 1.888 from zksync_sdk import ZkSyncLibrary

0 1.888 File "/usr/local/lib/python3.8/site-packages/zksync_sdk/init.py", line 1, in

0 1.888 from .ethereum_provider import EthereumProvider

0 1.888 File "/usr/local/lib/python3.8/site-packages/zksync_sdk/ethereum_provider.py", line 6, in

0 1.888 from zksync_sdk.types import Token

0 1.888 File "/usr/local/lib/python3.8/site-packages/zksync_sdk/types/init.py", line 3, in

0 1.888 from .responses import *

0 1.888 File "/usr/local/lib/python3.8/site-packages/zksync_sdk/types/responses.py", line 26, in

0 1.888 class NFT(Token):

0 1.888 File "/usr/local/lib/python3.8/site-packages/pydantic/_internal/_model_construction.py", line 98, in new

0 1.888 private_attributes = inspect_namespace(

0 1.888 File "/usr/local/lib/python3.8/site-packages/pydantic/_internal/_model_construction.py", line 337, in inspect_namespace

0 1.888 raise PydanticUserError(

0 1.888 pydantic.errors.PydanticUserError: Field 'decimals' defined on a base class was overridden by a non-annotated attribute. All field definitions, including overrides, require a type annotation.

0 1.888

0 1.888 For further information visit https://errors.pydantic.dev/2.1.1/u/model-field-overridden`

docker-compose build fails with other error.

oldwizard1010 commented 1 year ago
zksync_sdk/types/responses.py
class NFT(Token):
    creator_id: int
    content_hash: str
    creator_address: str
    serial_id: int
    decimals: int = 0

fix it like this