#ya-yang_api

1 messages ¡ Page 1 of 1 (latest)

spring thistleBOT
#

👋 Welcome to your new thread!

⏲️ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.

⏱️ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.

🔗 This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1313224711194284114

📝 Have more to share? Add more details, code, screenshots, videos, etc. below.

Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.

timid quiver
#

Hello, what line of Stripe code is throwing this error?

#

And what language is this v8.11.0 library?

rancid leaf
#

in python

#

when doing this import from stripe.error import InvalidRequestError

timid quiver
#

Gotcha, looking in to this and will get back to you

rancid leaf
#

Thanks! The documentation is showing that stripe.error.* is available

timid quiver
#

Hmm that same import is working for me albeit on a 10.X version. What version did you upgrade from? And are you having any issues importing anything else from Stripe?

rancid leaf
#

I upgraded from v5

#

Seeing the error when running this command pipenv run mypy hyke

#

Saw this changelog so wondering if we should only import from stripe

#

i'm also getting these two errors with the checkout.Session object...error: Item "None" of "Union[Price, None, Any]" has no attribute "id" error: Item "None" of "Optional[ListObject[LineItem]]" has no attribute "data"

#

and this is the code ``` session: stripe.checkout.Session = stripe.checkout.Session.retrieve(
session_id, expand=["line_items", "subscription"]
)

charged_price_ids = [line.price.id for line in session.line_items.data]```
#

I tested it in a shell, and it's working...

timid quiver
#

Interesting, so it is working in your shell but not your IDE basically?

rancid leaf
#

yeah works in the shell, but fails when checking types

timid quiver
#

Apologies still having trouble finding what this may be

#

What is your IDE? Or the specific thing that is checking types here?

spring thistleBOT
rancid leaf
#

mypy

#

I;m using vscode and using the mypy package for checking types

timid robin
#

Hi, stepping in and catching up.

rancid leaf
#

thanks

timid robin
#

When you saw that error, did you get a request id? Here's how you can find a request ID: https://support.stripe.com/questions/finding-the-id-for-an-api-request

You're saying that when you run this code using PHP, it throws the above errors?

session: stripe.checkout.Session = stripe.checkout.Session.retrieve(
session_id, expand=["line_items", "subscription"]
)

charged_price_ids = [line.price.id for line in session.line_items.data]
rancid leaf
#

I don't have a request id

#

this is a type error

#

the request still works

timid robin
#

What does I don't have a request id but the request still works mean?

rancid leaf
#

I didn't have errors with making the request. The error shows up when checking types using mypy package.

timid robin
#

Ah, I'm on the same page now. Further looking here.

arctic steeple
#

HI taking over here

#

I think this is an issue with your environment/type checker

#

Not an issue with the sdk

#

The code should still work

#

I'm not familiar with mypy, so don't have specific advice on how to resolve

#

But this isn't an issue with the sdk

#

Oh I wonder if this is due to the change in 7.8.0

#

Try from stripe import InvalidRequestError instead

#

Maybe the type checker is enforcing this deprecation

rancid leaf
#

Yeah i think it's enforcing the deprecation. But is Stripe still supporting those modules even though the changelog said they are deprecated? stripe.error, stripe.stripe_object, stripe.api_requestor, stripe.stripe_response, stripe.request_options, stripe.api_resources., stripe.api_resources.abstract.

arctic steeple
#

For now

#

They're deprecated those references still work for now

#

Not sure in what version they'll be strictly removed in

rancid leaf
#

Got it. Most of them are straight forward to fix. I just have a question about the checkout.Session object

#
        session_id, expand=["line_items", "subscription"]
    )

    charged_price_ids = [line.price.id for line in session.line_items.data]```
#

Im getting these two errors, but i do see the data and id properties in the Session payload.

#

error: Item "None" of "Union[Price, None, Any]" has no attribute "id"

error: Item "None" of "Optional[ListObject[LineItem]]" has no attribute "data"

#

Is there a problem with how they are accessed?

spring thistleBOT
arctic steeple
#

That code looks fine

#

Does it work?

#

I'm not sure what your type checker is complaining about

#

I think maybe it's because your code isn't handling the case that line_items could be of length 0 and that a line item might not have a price id

#

(but depending on what you do in your code it may not matter that you're not handling those cases)

#

Just the type checker catching potential issues