godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
91.38k stars 21.26k forks source link

SCons: Integrate `annotations` where relevant #99640

Open Repiteo opened 1 day ago

Repiteo commented 1 day ago

In hindsight, applying a static boilerplate to all Python files was far too excessive. It turns out there is full support for gradually integrating modern type-hint syntax via FA^1 instead. As such, this PR only integrates from __future__ import annotations on the files that can take immediate advantage of it:

# Before
from typing import List, Optional, Tuple, Union

def some_function(env: "ForwardDeclaredType") -> Optional[Tuple[List[str], Union[int, float]]]:

# After
from __future__ import annotations

def some_function(env: ForwardDeclaredType) -> tuple[list[str], int | float]] | None: