Skip to content

Commit 926b929

Browse files
committed
typing for root and core/ python files
1 parent e37c626 commit 926b929

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+523
-180
lines changed

SConstruct

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ from SCons.Builder import ListEmitter
2222
# folder when doing `import editor.template_builder`)
2323

2424

25-
def _helper_module(name, path):
25+
def _helper_module(name, path) -> None:
2626
spec = spec_from_file_location(name, path)
2727
module = module_from_spec(spec)
2828
spec.loader.exec_module(module)

core/SCsub

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,17 @@
22
from misc.utility.scons_hints import *
33

44
import os
5+
from typing import TYPE_CHECKING
56

67
import core_builders
78

89
import methods
910

11+
if TYPE_CHECKING:
12+
from godot_typing import GodotSConsEnvironment
13+
14+
env: "GodotSConsEnvironment"
15+
1016
Import("env")
1117

1218
env.core_sources = []
@@ -156,10 +162,8 @@ if env["builtin_zstd"]:
156162

157163
env_thirdparty.add_source_files(thirdparty_obj, thirdparty_zstd_sources)
158164

159-
160165
env.core_sources += thirdparty_obj
161166

162-
163167
# Godot source files
164168
env.add_source_files(env.core_sources, "*.cpp")
165169

@@ -222,7 +226,6 @@ SConscript("string/SCsub")
222226
SConscript("config/SCsub")
223227
SConscript("error/SCsub")
224228

225-
226229
# Build it all as a library
227230
lib = env.add_library("core", env.core_sources)
228231
env.Prepend(LIBS=[lib])

core/config/SCsub

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
#!/usr/bin/env python
22
from misc.utility.scons_hints import *
33

4+
from typing import TYPE_CHECKING
5+
6+
if TYPE_CHECKING:
7+
from godot_typing import GodotSConsEnvironment
8+
9+
env: "GodotSConsEnvironment"
410
Import("env")
511

612
env_config = env.Clone()

core/core_builders.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
"""Functions used to generate source files during build time"""
22

33
from collections import OrderedDict
4-
from io import TextIOWrapper
4+
from typing import TYPE_CHECKING
5+
6+
if TYPE_CHECKING:
7+
from io import TextIOWrapper
58

69
import methods
710

@@ -71,7 +74,7 @@ def encryption_key_builder(target, source, env):
7174
)
7275

7376

74-
def make_certs_header(target, source, env):
77+
def make_certs_header(target, source, env) -> None:
7578
buffer = methods.get_buffer(str(source[0]))
7679
decomp_size = len(buffer)
7780
buffer = methods.compress_buffer(buffer)
@@ -92,7 +95,7 @@ def make_certs_header(target, source, env):
9295
""")
9396

9497

95-
def make_authors_header(target, source, env):
98+
def make_authors_header(target, source, env) -> None:
9699
SECTIONS = {
97100
"Project Founders": "AUTHORS_FOUNDERS",
98101
"Lead Developer": "AUTHORS_LEAD_DEVELOPERS",
@@ -123,7 +126,7 @@ def close_section():
123126
close_section()
124127

125128

126-
def make_donors_header(target, source, env):
129+
def make_donors_header(target, source, env) -> None:
127130
SECTIONS = {
128131
"Patrons": "DONORS_PATRONS",
129132
"Platinum sponsors": "DONORS_SPONSORS_PLATINUM",
@@ -163,7 +166,7 @@ def make_license_header(target, source, env):
163166
src_license = str(source[1])
164167

165168
class LicenseReader:
166-
def __init__(self, license_file: TextIOWrapper):
169+
def __init__(self, license_file: "TextIOWrapper"):
167170
self._license_file = license_file
168171
self.line_num = 0
169172
self.current = self.next_line()

core/crypto/SCsub

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
#!/usr/bin/env python
22
from misc.utility.scons_hints import *
33

4+
from typing import TYPE_CHECKING
5+
6+
if TYPE_CHECKING:
7+
from godot_typing import GodotSConsEnvironment
8+
9+
env: "GodotSConsEnvironment"
410
Import("env")
511

612
env_crypto = env.Clone()

core/debugger/SCsub

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
#!/usr/bin/env python
22
from misc.utility.scons_hints import *
33

4+
from typing import TYPE_CHECKING
5+
6+
if TYPE_CHECKING:
7+
from godot_typing import GodotSConsEnvironment
8+
9+
env: "GodotSConsEnvironment"
410
Import("env")
511

612
env.add_source_files(env.core_sources, "*.cpp")

core/error/SCsub

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
#!/usr/bin/env python
22
from misc.utility.scons_hints import *
33

4+
from typing import TYPE_CHECKING
5+
6+
if TYPE_CHECKING:
7+
from godot_typing import GodotSConsEnvironment
8+
9+
env: "GodotSConsEnvironment"
410
Import("env")
511

612
env_error = env.Clone()

core/extension/SCsub

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
#!/usr/bin/env python
22
from misc.utility.scons_hints import *
33

4+
from typing import TYPE_CHECKING
5+
6+
if TYPE_CHECKING:
7+
from godot_typing import GodotSConsEnvironment
8+
9+
env: "GodotSConsEnvironment"
410
Import("env")
511

612
import make_interface_dumper

core/extension/make_interface_dumper.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import methods
22

33

4-
def run(target, source, env):
4+
def run(target, source, env) -> None:
55
buffer = methods.get_buffer(str(source[0]))
66
decomp_size = len(buffer)
77
buffer = methods.compress_buffer(buffer)

core/extension/make_wrappers.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
from typing import TYPE_CHECKING
2+
3+
if TYPE_CHECKING:
4+
from godot_typing import PositiveInt
15
proto_mod = """
26
#define MODBIND$VER($RETTYPE m_name$ARG) \\
37
virtual $RETVAL _##m_name($FUNCARGS) $CONST; \\
@@ -7,7 +11,7 @@
711
"""
812

913

10-
def generate_mod_version(argcount, const=False, returns=False):
14+
def generate_mod_version(argcount: "PositiveInt", const: bool = False, returns: bool = False) -> str:
1115
s = proto_mod
1216
sproto = str(argcount)
1317
if returns:
@@ -64,7 +68,7 @@ def generate_mod_version(argcount, const=False, returns=False):
6468
"""
6569

6670

67-
def generate_ex_version(argcount, const=False, returns=False):
71+
def generate_ex_version(argcount: "PositiveInt", const: bool = False, returns: bool = False) -> str:
6872
s = proto_ex
6973
sproto = str(argcount)
7074
if returns:
@@ -116,7 +120,7 @@ def generate_ex_version(argcount, const=False, returns=False):
116120
return s
117121

118122

119-
def run(target, source, env):
123+
def run(target, source, env) -> None:
120124
max_versions = 12
121125

122126
txt = "#pragma once"

core/input/SCsub

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
#!/usr/bin/env python
22
from misc.utility.scons_hints import *
33

4+
from typing import TYPE_CHECKING
5+
6+
if TYPE_CHECKING:
7+
from godot_typing import GodotSConsEnvironment
8+
9+
env: "GodotSConsEnvironment"
410
Import("env")
511

612
import input_builders

core/input/input_builders.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
"""Functions used to generate source files during build time"""
22

33
from collections import OrderedDict
4+
from typing import Any
45

56
import methods
67

78

8-
def make_default_controller_mappings(target, source, env):
9+
def make_default_controller_mappings(target, source, env) -> None:
910
with methods.generated_wrapper(str(target[0])) as file:
1011
file.write("""\
1112
#include "core/input/default_controller_mappings.h"
@@ -15,7 +16,7 @@ def make_default_controller_mappings(target, source, env):
1516
""")
1617

1718
# ensure mappings have a consistent order
18-
platform_mappings = OrderedDict()
19+
platform_mappings: OrderedDict[Any, Any] = OrderedDict()
1920
for src_path in map(str, source):
2021
with open(src_path, "r", encoding="utf-8") as f:
2122
# read mapping file and skip header

core/io/SCsub

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
#!/usr/bin/env python
22
from misc.utility.scons_hints import *
33

4+
from typing import TYPE_CHECKING
5+
6+
if TYPE_CHECKING:
7+
from godot_typing import GodotSConsEnvironment
8+
9+
env: "GodotSConsEnvironment"
410
Import("env")
511

612
env.add_source_files(env.core_sources, "*.cpp")

core/math/SCsub

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
#!/usr/bin/env python
22
from misc.utility.scons_hints import *
33

4+
from typing import TYPE_CHECKING
5+
6+
if TYPE_CHECKING:
7+
from godot_typing import GodotSConsEnvironment
8+
9+
env: "GodotSConsEnvironment"
410
Import("env")
511

612
env_math = env.Clone()

core/object/SCsub

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
#!/usr/bin/env python
22
from misc.utility.scons_hints import *
33

4+
from typing import TYPE_CHECKING
5+
6+
if TYPE_CHECKING:
7+
from godot_typing import GodotSConsEnvironment
8+
9+
env: "GodotSConsEnvironment"
410
Import("env")
511

612
import make_virtuals

core/object/make_virtuals.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
from typing import TYPE_CHECKING
2+
3+
if TYPE_CHECKING:
4+
from godot_typing import PositiveInt
15
script_call = """ScriptInstance *_script_instance = ((Object *)(this))->get_script_instance();\\
26
if (_script_instance) {\\
37
Callable::CallError ce;\\
@@ -88,7 +92,9 @@
8892
"""
8993

9094

91-
def generate_version(argcount, const=False, returns=False, required=False, compat=False):
95+
def generate_version(
96+
argcount: "PositiveInt", const: bool = False, returns: bool = False, required: bool = False, compat: bool = False
97+
) -> str:
9298
s = proto
9399
if compat:
94100
s = s.replace("$SCRIPTCALL", "")
@@ -211,7 +217,7 @@ def generate_version(argcount, const=False, returns=False, required=False, compa
211217
return s
212218

213219

214-
def run(target, source, env):
220+
def run(target, source, env) -> None:
215221
max_versions = 12
216222

217223
txt = """/* THIS FILE IS GENERATED DO NOT EDIT */

core/os/SCsub

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
#!/usr/bin/env python
22
from misc.utility.scons_hints import *
33

4+
from typing import TYPE_CHECKING
5+
6+
if TYPE_CHECKING:
7+
from godot_typing import GodotSConsEnvironment
8+
9+
env: "GodotSConsEnvironment"
410
Import("env")
511

612
env.add_source_files(env.core_sources, "*.cpp")

core/string/SCsub

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
#!/usr/bin/env python
22
from misc.utility.scons_hints import *
33

4+
from typing import TYPE_CHECKING
5+
6+
if TYPE_CHECKING:
7+
from godot_typing import GodotSConsEnvironment
8+
9+
env: "GodotSConsEnvironment"
410
Import("env")
511

612
env_string = env.Clone()

core/templates/SCsub

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
#!/usr/bin/env python
22
from misc.utility.scons_hints import *
33

4+
from typing import TYPE_CHECKING
5+
6+
if TYPE_CHECKING:
7+
from godot_typing import GodotSConsEnvironment
8+
9+
env: "GodotSConsEnvironment"
410
Import("env")
511

612
env_templates = env.Clone()

core/variant/SCsub

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
#!/usr/bin/env python
22
from misc.utility.scons_hints import *
33

4+
from typing import TYPE_CHECKING
5+
6+
if TYPE_CHECKING:
7+
from godot_typing import GodotSConsEnvironment
8+
9+
env: "GodotSConsEnvironment"
410
Import("env")
511

612
env_variant = env.Clone()

0 commit comments

Comments
 (0)