lnbits / lnurl

LNURL implementation for Python.
https://pypi.org/project/lnurl
MIT License
64 stars 19 forks source link

[FEAT] update to pydantic2 #21

Open dni opened 1 year ago

dni commented 1 year ago

this request a new major version and i will release 1.0.0 if this PR works

closes #18

brianoflondon commented 1 year ago

I think this pydantic.errors.PydanticImportError:pydantic:ConstrainedStrhas been removed in V2. needs to be fixed before this can be marked done.

ImportError while importing test module '/Users/bol/Documents/dev/v4vapp/v4vapp-api-ext/tests/podcastindex/test_pi_get.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/Users/bol/.pyenv/versions/3.11.1/lib/python3.11/importlib/__init__.py:126: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
tests/podcastindex/test_pi_get.py:4: in <module>
    from v4vapp_api_ext.main import app
src/v4vapp_api_ext/main.py:23: in <module>
    from v4vapp_api_ext.helpers.qr_code_avatar import get_hive_avatar
src/v4vapp_api_ext/helpers/qr_code_avatar.py:10: in <module>
    from lnurl import encode as lnurl_encode
/Users/bol/Library/Caches/pypoetry/virtualenvs/v4vapp-api-ext-cc3pDiTe-py3.11/lib/python3.11/site-packages/lnurl/__init__.py:3: in <module>
    from .core import decode, encode, get, handle
/Users/bol/Library/Caches/pypoetry/virtualenvs/v4vapp-api-ext-cc3pDiTe-py3.11/lib/python3.11/site-packages/lnurl/core.py:8: in <module>
    from .models import LnurlAuthResponse, LnurlResponse, LnurlResponseModel
/Users/bol/Library/Caches/pypoetry/virtualenvs/v4vapp-api-ext-cc3pDiTe-py3.11/lib/python3.11/site-packages/lnurl/models.py:7: in <module>
    from .types import (
/Users/bol/Library/Caches/pypoetry/virtualenvs/v4vapp-api-ext-cc3pDiTe-py3.11/lib/python3.11/site-packages/lnurl/types.py:8: in <module>
    from pydantic import (
/Users/bol/Library/Caches/pypoetry/virtualenvs/v4vapp-api-ext-cc3pDiTe-py3.11/lib/python3.11/site-packages/pydantic/__init__.py:210: in __getattr__
    return _getattr_migration(attr_name)
/Users/bol/Library/Caches/pypoetry/virtualenvs/v4vapp-api-ext-cc3pDiTe-py3.11/lib/python3.11/site-packages/pydantic/_migration.py:295: in wrapper
    raise PydanticImportError(f'`{import_path}` has been removed in V2.')
E   pydantic.errors.PydanticImportError: `pydantic:ConstrainedStr` has been removed in V2.
E   
E   For further information visit https://errors.pydantic.dev/2.1.1/u/import-error
dni commented 1 year ago

sorry its still a draft :D is going to be a pretty substantial change

brianoflondon commented 1 year ago

Ahh thanks, yeah I thought it would be a bit more intense. I've been fortunate, none of my other API projects have had any issues switching so far.

dyKiU commented 1 year ago

Looked at migration of class LightningNodeUri here The only way I could make it work is to inject a 'lightning://' to make it a valid URL. The tests needed a change which hints at incompatibity going forward. The proper fix would involve changing the rust validation engine. I hope this helps somehow.