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

The --convert-3to4 flag removes spaces around commas #74204

Closed
Tracked by #73960
rcorre opened this issue Mar 2, 2023 · 0 comments · Fixed by #74232
Closed
Tracked by #73960

The --convert-3to4 flag removes spaces around commas #74204

rcorre opened this issue Mar 2, 2023 · 0 comments · Fixed by #74232

Comments

@rcorre
Copy link
Contributor

rcorre commented Mar 2, 2023

Godot version

4.0-stable

System information

Linux

Issue description

The style guide says

Always use one space around operators and after commas

However, the 3to4 tool will remove these spaces when converting connect and init

-               timer.connect("timeout", visual, "queue_free")
+               timer.connect("timeout",Callable(visual,"queue_free"))

-       func _init(section: String, key: String, default: int, bounds: PoolIntArray).(section, key, default) -> void:
+       func _init(section: String,key: String,default: int,bounds: PackedInt32Array,section,key,default):

Steps to reproduce


func _ready() -> void:
        connect("visibility_changed",Callable(self,"_on_visibility_changed"))

func _on_visibility_changed():
        pass

Write this to Example.gd in a godot3 project, then run godot4 --convert-3to4

Minimal reproduction project

example.zip

@akien-mga akien-mga added this to the 4.1 milestone Mar 2, 2023
JeffVenancius pushed a commit to JeffVenancius/godot that referenced this issue Mar 3, 2023
Fixes godotengine#74204.

The style guide says

> Always use one space around operators and after commas

The 3to4 conversion tool currently strips space in certain scenarios.
I've updated it to add space whenever it is generating new code.
In any case where it substitutes existing code, it leaves it as-is.

For example, connect(a,b,c) becomes `connect(a, callable(b, c))`, because the converter is adding new commads/parens.

However, `xform(Vector3(a,b,c))` becomes `Transform * Vector3(a,b,c)` because it uses the user's original Vector3 string whole. If the user originally had `xform(Vector3(a, b, c))`, then it becomes `Transform * Vector3(a, b, c)`.

Ideally we'd always preserve original formatting, but this seems quite difficult, so I tried to preserve it where we can, but air on the side of following the style guide whenever we're transforming code.
YuriSizov pushed a commit to YuriSizov/godot that referenced this issue Mar 13, 2023
Fixes godotengine#74204.

The style guide says

> Always use one space around operators and after commas

The 3to4 conversion tool currently strips space in certain scenarios.
I've updated it to add space whenever it is generating new code.
In any case where it substitutes existing code, it leaves it as-is.

For example, connect(a,b,c) becomes `connect(a, callable(b, c))`, because the converter is adding new commads/parens.

However, `xform(Vector3(a,b,c))` becomes `Transform * Vector3(a,b,c)` because it uses the user's original Vector3 string whole. If the user originally had `xform(Vector3(a, b, c))`, then it becomes `Transform * Vector3(a, b, c)`.

Ideally we'd always preserve original formatting, but this seems quite difficult, so I tried to preserve it where we can, but air on the side of following the style guide whenever we're transforming code.

(cherry picked from commit d3684e6)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants