New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rect is iterable but not typed or documented #2681
Comments
I knew about this, I don't remember how though. Rect objects are just supposed to behave like sequences of 4 numbers, and iteration is part of that. They can also be directly indexed, is getitem typed? It would be great to have a small note in the docs about these two behaviors. Anyways, I think |
Related to this issue, |
is there a way to do destructuring assignment that isn't exposing an iterator? |
Hi, I would like to contribute to this issue, I can submit a PR with a misc typehints fix within 2 days if this is fine with @ankith26 and others? |
AFAIK that's not possible ATM with python
Yeah, that would be cool for me! But I had recommended this issue to @Jumana-22 as well, so could you decide with them on who would work on this issue, so that we don't have 2 people working on the same issue :) |
Hi @Jumana-22, wondering if you would like to take on this issue. I believe I have a fix for this issue but if you would like to take this on I will contribute in other ways! |
It looks like this issue hasn't moved anywhere in a while. I'll start working on it. |
Did we reject the idea of making Rect not iterable, not quacking like a 4-item sequence? I think maybe there was a discussion on Discord about
being allowed but always returning If people want the coordinates out we could add an attribute like |
Hmm I just did some digging, and it turns out, Also, |
(Removing the good first issue label because this one isn't so clear what there is to do) |
Cannot |
No, IMHO we shouldn't make
|
That's a waste of effort and going in the wrong direction. I don't think we need an |
|
As you already say, these objects are already iterable. Since pygame objects like vector, color, rect (and maybe other stuff IDK) implement a subset of the sequence protocol in the C code, many things already rely on these objects being iterable. Well it can be seen as a problem on the python end, because ATM, having a |
So, it seems that
Rect
is iterable and you can doHowever I do not see this documented anywhere, nor exposed in the type hints. Thus, Mypy complains but the code works.
Is this an oversight, or is this feature not supposed to be used?
The text was updated successfully, but these errors were encountered: