pyQiwiP2P pay_sources: 列表[str] = None

pyQiwiP2P pay_sources: list[str] = None

我需要通过qiwi支付

from pyqiwip2p import QiwiP2P
from pyqiwip2p.Qiwip2p import PaymentMethods  

def create_trans(amount=400, lifetime=30, comment="def"):
        p2p = QiwiP2P(auth_key="I specifically removed")
        bill = p2p.bill(amount=amount, lifetime=lifetime, comment=comment, bill_id=random_id, pay_sources=[PaymentMethods.qiwi, PaymentMethods.card, PaymentMethods.mobile])
        return bill

程序以错误结束:

File "G:\bot\venv\lib\site-packages\pyqiwip2p\Qiwip2p.py", line 118, in QiwiP2P    
pay_sources: list[str] = None,
TypeError: 'type' object is not subscriptable

这看起来是 pyQiwiP2P 中的错误。

根据您的回溯,line 118 of pyqiwip2p.Qiwip2p.py 如下:

        pay_sources: list[str] = None,

这包含损坏的类型提示,list[str]。作者似乎想添加一个类型提示,说明方法参数 pay_sources 应该包含一个字符串列表。在这种情况下,他们应该写

        pay_sources: typing.List[str] = None,

或者也许

        pay_sources: typing.Union[typing.List[str], None] = None,

相反,鉴于 pay_sources 也可以是 None

为确认是这种情况,我们可以在 Python 交互式会话中轻松重现您的异常:

>>> def test(a: list[str]):
...     pass
...
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'type' object is not subscriptable

我建议您与软件包作者联系,也许可以在 project's GitHub repository.

上提出问题