botostubs
botostubs copied to clipboard
botostubs showing details for get_paginator, but not actual api call
botostubs type hinting, hover for get_paginator works fine. hover over "list_policies" doesn't work. autocomplete where "list_policies" doesn't work. It be nice if botostubs can be updated to handle things, when we have to use pagination.
` import boto3 import botostubs org_client = boto3.client("organizations") # type: botostubs.Organizations
def get_policies(filter): paginator = org_client.get_paginator("list_policies") policies = [] for page in paginator.paginate(Filter=filter): policies.extend(page.get("Policies")) return policies `
Hello Julio, botostubs does support paginators. You have to declare the type hint just like client classes. Try this:
paginator = org_client.get_paginator("list_policies") # type: botostubs.Organizations.ListPoliciesPaginator
Let me know if I misunderstood your question
Will test that out. However, I would prefer it would figure that out automatically, without me having to add separate type hints everywhere I use paginators. For instance, when doing calls without paginating, I don't have to add separate type hints, just having the main type hint when I declare the client, is sufficient.
org_client = boto3.client("organizations") # type: botostubs.Organizations org_info = org_client.describe_organization().get("Organization")
Example where it works nicely (without paginators), without me adding type hints to each API call
it be great, if botostubs handled that automatically, whenever it saw "get_paginator" being used. Other reason why its helpful, is so that its easy to comment out botostubs when no longer needed, or being deployed as a solution. Only have to comment the import line and the type hints in the client lines. If I have to add this for paginators separately, that is more lines to add comments too.
On another note, put in another ticket I think, to see if there is a method to use botostubs, without having to add type hints at all to each line, instead import botostubs, and then all works. that would be sweet. I primarily use Visual Studio Code, fyi.
I would prefer it would figure that out automatically
Yeah but I only included type hints that will work in many IDEs. Such feature that you're describing needs expertise on IDE-specific plugin dev which I don't have.
its easy to comment out botostubs when no longer needed
Instead of commenting it, I suggest you write it like this:
try:
import botostubs
except:
pass
If I have to add this for paginators separately, that is more lines to add comments too
If you're using the type hints as comments, then you don't need to comment them, right?
try/except worked out great. errors I was still getting was my linters, and doing try/except got rid of those errors too.
I was thinking something like function overloads, similar to boto3-stubs (https://pypi.org/project/boto3-stubs/), and it doesn't require any IDE extensions to make it work. Or using pylance that just got released by microsoft visual studio code, where you can point at stubs in a directory, and it dynamically reads it. Just thoughts.
thanks for the help. much appreciated.