-
Notifications
You must be signed in to change notification settings - Fork 10
Fix Vec2/3/4 #286
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
base: main
Are you sure you want to change the base?
Fix Vec2/3/4 #286
Conversation
icon.sDisabledIconId = sDisabledIconId | ||
icon.sInspectorLabel = sInspectorLabel | ||
icon.vAnchorOffset = list(vAnchorOffset) | ||
icon.vAnchorOffset = Vec2(*vAnchorOffset) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should probably just make this take a Vec2 as the argument
return None | ||
return ValueError(f"Invalid CVector{length}D: {__value}") | ||
|
||
return None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you should keep this length check, since isinstance(Vec4(0.0, 0.0, 0.0, 0.0), Vec2)
is true. the float check isn't strictly necessary but doesn't hurt
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want that to explicitly fail? Shouldn't you be using type(Vec4(0.0, 0.0, 0.0, 0.0)) is Vec2
if you want to exclude subclasses?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you could you use that instead of this length check if you prefer. still needs to be a special case tho
tests/test_type_lib.py
Outdated
("base::math::CVector2D", ["foo", "bar"], TypeError("Expected Vec2; got list")), | ||
("base::math::CVector2D", [0.0], TypeError("Expected Vec2; got list")), | ||
("base::math::CVector3D", [0.0], TypeError("Expected Vec3; got list")), | ||
("base::math::CVector4D", [0.0], TypeError("Expected Vec4; got list")), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
likewise, add test cases where you pass a Vec3 and a Vec4 to a Vec2 field and ensure they error
No description provided.