Skip to content

Commit

Permalink
CI: Add module dependencies to mypy hook
Browse files Browse the repository at this point in the history
  • Loading branch information
Repiteo committed Nov 24, 2024
1 parent 0c45ace commit 5e5a50c
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 38 deletions.
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ repos:
- id: mypy
files: \.py$
types_or: [text]
additional_dependencies: [scons==4.8.1, pytest==7.1.2]

- repo: https://github.com/codespell-project/codespell
rev: v2.3.0
Expand Down
12 changes: 5 additions & 7 deletions platform/android/detect.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@
import platform
import subprocess
import sys
from typing import TYPE_CHECKING

from SCons.Script.SConscript import SConsEnvironment

from methods import print_error, print_warning
from platform_methods import validate_arch

if TYPE_CHECKING:
from SCons.Script.SConscript import SConsEnvironment


def get_name():
return "Android"
Expand Down Expand Up @@ -54,7 +52,7 @@ def get_min_sdk_version(platform):
return int(platform.split("-")[1])


def get_android_ndk_root(env: "SConsEnvironment"):
def get_android_ndk_root(env: SConsEnvironment):
return env["ANDROID_HOME"] + "/ndk/" + get_ndk_version()


Expand All @@ -78,7 +76,7 @@ def get_flags():

# Check if Android NDK version is installed
# If not, install it.
def install_ndk_if_needed(env: "SConsEnvironment"):
def install_ndk_if_needed(env: SConsEnvironment):
sdk_root = env["ANDROID_HOME"]
if not os.path.exists(get_android_ndk_root(env)):
extension = ".bat" if os.name == "nt" else ""
Expand Down Expand Up @@ -106,7 +104,7 @@ def detect_swappy():
return has_swappy


def configure(env: "SConsEnvironment"):
def configure(env: SConsEnvironment):
# Validate arch.
supported_arches = ["x86_32", "x86_64", "arm32", "arm64"]
validate_arch(env["arch"], get_name(), supported_arches)
Expand Down
8 changes: 3 additions & 5 deletions platform/ios/detect.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import os
import sys
from typing import TYPE_CHECKING

from SCons.Script.SConscript import SConsEnvironment

from methods import detect_darwin_sdk_path, print_error, print_warning
from platform_methods import validate_arch

if TYPE_CHECKING:
from SCons.Script.SConscript import SConsEnvironment


def get_name():
return "iOS"
Expand Down Expand Up @@ -58,7 +56,7 @@ def get_flags():
}


def configure(env: "SConsEnvironment"):
def configure(env: SConsEnvironment):
# Validate arch.
supported_arches = ["x86_64", "arm64"]
validate_arch(env["arch"], get_name(), supported_arches)
Expand Down
8 changes: 3 additions & 5 deletions platform/linuxbsd/detect.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import os
import platform
import sys
from typing import TYPE_CHECKING

from SCons.Script.SConscript import SConsEnvironment

from methods import get_compiler_version, print_error, print_warning, using_gcc
from platform_methods import detect_arch, validate_arch

if TYPE_CHECKING:
from SCons.Script.SConscript import SConsEnvironment


def get_name():
return "LinuxBSD"
Expand Down Expand Up @@ -71,7 +69,7 @@ def get_flags():
}


def configure(env: "SConsEnvironment"):
def configure(env: SConsEnvironment):
# Validate arch.
supported_arches = ["x86_32", "x86_64", "arm32", "arm64", "rv64", "ppc32", "ppc64"]
validate_arch(env["arch"], get_name(), supported_arches)
Expand Down
8 changes: 3 additions & 5 deletions platform/macos/detect.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import os
import sys
from typing import TYPE_CHECKING

from SCons.Script.SConscript import SConsEnvironment

from methods import detect_darwin_sdk_path, get_compiler_version, is_apple_clang, print_error, print_warning
from platform_methods import detect_arch, detect_mvk, validate_arch

if TYPE_CHECKING:
from SCons.Script.SConscript import SConsEnvironment

# To match other platforms
STACK_SIZE = 8388608
STACK_SIZE_SANITIZERS = 30 * 1024 * 1024
Expand Down Expand Up @@ -65,7 +63,7 @@ def get_flags():
}


def configure(env: "SConsEnvironment"):
def configure(env: SConsEnvironment):
# Validate arch.
supported_arches = ["x86_64", "arm64"]
validate_arch(env["arch"], get_name(), supported_arches)
Expand Down
7 changes: 2 additions & 5 deletions platform/web/detect.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import os
import sys
from typing import TYPE_CHECKING

from emscripten_helpers import (
add_js_externs,
Expand All @@ -11,14 +10,12 @@
get_template_zip_path,
run_closure_compiler,
)
from SCons.Script.SConscript import SConsEnvironment
from SCons.Util import WhereIs

from methods import get_compiler_version, print_error, print_warning
from platform_methods import validate_arch

if TYPE_CHECKING:
from SCons.Script.SConscript import SConsEnvironment


def get_name():
return "Web"
Expand Down Expand Up @@ -84,7 +81,7 @@ def get_flags():
}


def configure(env: "SConsEnvironment"):
def configure(env: SConsEnvironment):
# Validate arch.
supported_arches = ["wasm32"]
validate_arch(env["arch"], get_name(), supported_arches)
Expand Down
20 changes: 9 additions & 11 deletions platform/windows/detect.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@
import re
import subprocess
import sys
from typing import TYPE_CHECKING

from SCons.Script.SConscript import SConsEnvironment

import methods
from methods import print_error, print_warning
from platform_methods import detect_arch, validate_arch

if TYPE_CHECKING:
from SCons.Script.SConscript import SConsEnvironment

# To match other platforms
STACK_SIZE = 8388608
STACK_SIZE_SANITIZERS = 30 * 1024 * 1024
Expand Down Expand Up @@ -79,7 +77,7 @@ def get_mingw_bin_prefix(prefix, arch):
return bin_prefix + arch_prefix


def get_detected(env: "SConsEnvironment", tool: str) -> str:
def get_detected(env: SConsEnvironment, tool: str) -> str:
checks = [
get_mingw_bin_prefix(env["mingw_prefix"], env["arch"]) + tool,
get_mingw_bin_prefix(env["mingw_prefix"], "") + tool,
Expand Down Expand Up @@ -245,7 +243,7 @@ def get_flags():
}


def setup_msvc_manual(env: "SConsEnvironment"):
def setup_msvc_manual(env: SConsEnvironment):
"""Running from VCVARS environment"""

env_arch = detect_build_env_arch()
Expand All @@ -260,7 +258,7 @@ def setup_msvc_manual(env: "SConsEnvironment"):
print("Using VCVARS-determined MSVC, arch %s" % (env_arch))


def setup_msvc_auto(env: "SConsEnvironment"):
def setup_msvc_auto(env: SConsEnvironment):
"""Set up MSVC using SCons's auto-detection logic"""

# If MSVC_VERSION is set by SCons, we know MSVC is installed.
Expand Down Expand Up @@ -302,7 +300,7 @@ def setup_msvc_auto(env: "SConsEnvironment"):
print("Using SCons-detected MSVC version %s, arch %s" % (env["MSVC_VERSION"], env["arch"]))


def setup_mingw(env: "SConsEnvironment"):
def setup_mingw(env: SConsEnvironment):
"""Set up env for use with mingw"""

env_arch = detect_build_env_arch()
Expand Down Expand Up @@ -333,7 +331,7 @@ def setup_mingw(env: "SConsEnvironment"):
print("Using MinGW, arch %s" % (env["arch"]))


def configure_msvc(env: "SConsEnvironment", vcvars_msvc_config):
def configure_msvc(env: SConsEnvironment, vcvars_msvc_config):
"""Configure env to work with MSVC"""

## Build type
Expand Down Expand Up @@ -670,7 +668,7 @@ def tempfile_arg_esc_func(arg):
return WINPATHSEP_RE.sub(r"/\1", arg)


def configure_mingw(env: "SConsEnvironment"):
def configure_mingw(env: SConsEnvironment):
# Workaround for MinGW. See:
# https://www.scons.org/wiki/LongCmdLinesOnWin32
env.use_windows_spawn_fix()
Expand Down Expand Up @@ -900,7 +898,7 @@ def configure_mingw(env: "SConsEnvironment"):
env.Append(CPPDEFINES=["MINGW_ENABLED", ("MINGW_HAS_SECURE_API", 1)])


def configure(env: "SConsEnvironment"):
def configure(env: SConsEnvironment):
# Validate arch.
supported_arches = ["x86_32", "x86_64", "arm32", "arm64"]
validate_arch(env["arch"], get_name(), supported_arches)
Expand Down

0 comments on commit 5e5a50c

Please sign in to comment.