Skip to content
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

Sequences are not recognized as vectors/matrices/quaternions. #2

Open
esoma opened this issue Oct 24, 2021 · 0 comments
Open

Sequences are not recognized as vectors/matrices/quaternions. #2

esoma opened this issue Oct 24, 2021 · 0 comments
Assignees
Labels

Comments

@esoma
Copy link
Owner

esoma commented Oct 24, 2021

PyGLM often accepts appropriately composed sequences as vec, mat or quat types.

import glm
x = glm.vec3([1, 2, 3])
print(x) # vec3(1, 2, 3)

However, glm_typing considers this an error -- it does not recognize arbitrary sequences as compatible with vec, mat and quat. This was a conscious decision to provide more precise type checking. See:

import glm
x = glm.vec3(glm.vec2()) # TypeError

We are unable to create a vec3 from a smaller vec2. If arbitrary sequences were allowed in the vec3 constructor, then glm_typing would not detect this error (since all vecs are also sequences). This intersection between the PyGLM types and Sequence causes this issue.

It's worth noting that tuples of non-arbitrary size are still accepted properly (since their shape is known statically).

It is probably possible to allow the sequence behavior with a mypy plugin, but I've not felt the need for it. Let me know in this issue if it's something you'd need.

@esoma esoma added the info label Oct 24, 2021
@esoma esoma self-assigned this Oct 24, 2021
@esoma esoma changed the title Sequences are not recognized as vectors/matrices. Sequences are not recognized as vectors/matrices/quaternions. Oct 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant