michaelhly / solana-py

Solana Python SDK
https://michaelhly.github.io/solana-py
MIT License
979 stars 252 forks source link

Better type hinting for make_request on AsyncHTTPProvider #446

Closed nhruo123 closed 1 month ago

nhruo123 commented 1 month ago

Problem: Due to the untyped decorator handle_async_exceptions the function make_request on AsyncHTTPProvider is untyped as well. This causes issues with LSP code completion and with mypy in general (because mypy thinks make_request returns Any).

Steps to reproduce:

  1. Create a project using strict mode in mypy
  2. Call make_request on AsyncHTTPProvider
  3. Call reveal_type on the returned type

Expected Behavior: Instead of Any reveal_type should show the T that is passed to make_request.

This should be easy to fix, adding type hints on handle_async_exceptions would solve the issue here, I won't mind creating a PR for that.

michaelhly commented 1 month ago

Makes sense. Feel free to create a PR!