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

Remove uses of static typing from the documentation #99925

Merged

Conversation

Mickeon
Copy link
Contributor

@Mickeon Mickeon commented Dec 2, 2024

Related to #99924
See #99325 (comment) and prior comments

TL:DR: We shouldn't use static typing in the documentation (unless it's relevant to the code example). At least not yet.

This is not the same PR as #99924.
The reason I decided to split the two is because the choice is not as clear-cut. Removing some of these static types may actually make the code examples worse, as I'll comment below.

@Mickeon Mickeon added this to the 4.x milestone Dec 2, 2024
@Mickeon Mickeon requested review from a team as code owners December 2, 2024 15:00
@Mickeon Mickeon removed the request for review from a team December 2, 2024 15:00
@onready var character_name: Label = $Label
@onready var character_name = $Label
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Narrowing down the type of an @onready variable is good practice but by hard-following the general rule this should be removed.

Comment on lines 22 to +23
var texture = load("res://icon.svg")
var image: Image = texture.get_image()
var image = texture.get_image()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no guarantee that texture is a Texture, and that it has the get_image() method, so this is another example of type narrowing.

Comment on lines -12 to +13
var heightmap_texture: Texture = ResourceLoader.load("res://heightmap_image.exr")
var heightmap_image: Image = heightmap_texture.get_image()
var heightmap_texture = ResourceLoader.load("res://heightmap_image.exr")
var heightmap_image = heightmap_texture.get_image()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is type narrowing again.

@Mickeon Mickeon modified the milestones: 4.x, 4.4 Dec 2, 2024
Copy link
Member

@mhilbrunner mhilbrunner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fine by me; agree with the reasoning (if we were to do this, we need to decide about how/when), and the change looks good to me.

@akien-mga akien-mga merged commit 4866c4a into godotengine:master Dec 17, 2024
20 checks passed
@akien-mga
Copy link
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants