-
Notifications
You must be signed in to change notification settings - Fork 103
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
Improve static typing support #588
Conversation
Does checking "Exclude Addons" still cause errors? If so, then I might consider these changes. GUT was started long before static typing was widely used and |
Yes, because a test file is not an addon, hence you will get errors. |
Just noticed that |
This should be fixed soon via #601. |
@mphe I'm still thinking about this. It feels like it is opening a can of worms. With that in mind, I had the horrible idea of moving the directory containing your tests to the I would love to hear any opinions about this. I know I would be hesitant to do it in my own project, it feels gross. It might be the best way to workaround the issues you've come across and any future related issues until Godot offers a way to exclude an arbitrary directory. |
I think the can of worms is already open and it's time to put the worms back and close the lid. #600 just helps for not having to manually change project settings before running the test suite, it doesn't help with diagnostics in editor. Hence, I think it's better to gradually try to fix typing related errors as far as possible. |
I'm ok with Some other gut.gd class_name choicesCannot Use
Other Choices
Best
Unnecessary Author Rant
My gut reaction (pun intended) was "GUT works fine, this is at best a usability enhancement, not an internal GUT issue." The more static typing I have to do in a dynamic, interpreted language the more annoyed I become. I would like GUT to be usable by as many people as possible and people like these features. They can also have performance benefits so GUT should try to accomodate this style as much as it can. I will, however, go crazy-go-nuts when "GDTypeScript" is created by some statically typed zealot (one who is a zealot for statically typed features and/or |
Renamed Regarding your rant: Also, nice pun. |
Types can help in some spots, but with decent naming and unit/integration tests (and occasionally some comments) you can get by just fine without them. I started GUT in Godot 2.x and I haven't felt the need to use static typing more. Sometimes user facing methods have to be more complicated due to type checking, but not often. In my personal projects I use types a little more, mostly for the autocomplete. |
I enabled various warnings in
debug/gdscript
related to enforcing static typing, e.g.unsafe_property_access
orunsafe_method_access
.I also treat some of them as errors.
I've just wrote a unit test and immediately ran into errors because Gut doesn't seem to make much use of static typing.
This patch gives the
gut
object aclass_name
and adds an explicit return type to theget_elapsed_time
function.I'm not sure if
GutContext
is a sensible name for this class, I'm open for suggestions.This patch just contains fixes for the parts that immediately caused errors in my workflow.
There might be more PRs to come in the future if I run into trouble again :)