Fix `pyright` complaints and run `black` (#12)

This commit is contained in:
Robin Avery 2024-02-29 13:21:44 -05:00 committed by GitHub
parent 2e4bd593e5
commit bf77cea86d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 16 additions and 13 deletions

4
.flake8 Normal file
View File

@ -0,0 +1,4 @@
[flake8]
# E203: whitespace before ':'
# E501: line too long
extend-ignore = E203,E501

View File

@ -21,10 +21,9 @@ use Python.
import re
import textwrap
from typing import Optional, Union, Tuple, Match, Dict, List
from io import StringIO
from pathlib import Path
from typing import Dict, List, Match, Optional, Tuple, Union
NinjaPath = Union[str, Path]
NinjaPaths = Union[
@ -125,17 +124,17 @@ class Writer(object):
if implicit:
implicit = [escape_path(x) for x in serialize_paths(implicit)]
all_inputs.append("|")
all_inputs.extend(implicit)
all_inputs.extend(map(str, implicit))
if order_only:
order_only = [escape_path(x) for x in serialize_paths(order_only)]
all_inputs.append("||")
all_inputs.extend(order_only)
all_inputs.extend(map(str, order_only))
if implicit_outputs:
implicit_outputs = [
escape_path(x) for x in serialize_paths(implicit_outputs)
]
out_outputs.append("|")
out_outputs.extend(implicit_outputs)
out_outputs.extend(map(str, implicit_outputs))
self._line(
"build %s: %s" % (" ".join(out_outputs), " ".join([rule] + all_inputs))

View File

@ -12,13 +12,13 @@
import io
import json
import math
import os
import platform
import sys
import math
from typing import Optional, Union, Tuple, Dict, List, Set, Any
from pathlib import Path
from typing import Any, Dict, List, Optional, Set, Tuple, Union
from . import ninja_syntax
if sys.platform == "cygwin":
@ -204,6 +204,7 @@ def generate_build_ninja(
n.comment("Tooling")
build_path = config.out_path()
progress_path = build_path / "progress.json"
build_tools_path = config.build_dir / "tools"
download_tool = config.tools_dir / "download_tool.py"
n.rule(
@ -417,8 +418,8 @@ def generate_build_ninja(
self.entry = config["entry"]
self.inputs: List[str] = []
def add(self, obj: str) -> None:
self.inputs.append(obj)
def add(self, obj: os.PathLike) -> None:
self.inputs.append(str(obj))
def output(self) -> Path:
if self.module_id == 0:
@ -460,7 +461,7 @@ def generate_build_ninja(
else:
preplf_path = build_path / self.name / f"{self.name}.preplf"
plf_path = build_path / self.name / f"{self.name}.plf"
preplf_ldflags = f"$ldflags -sdata 0 -sdata2 0 -r"
preplf_ldflags = "$ldflags -sdata 0 -sdata2 0 -r"
plf_ldflags = f"$ldflags -sdata 0 -sdata2 0 -r1 -lcf {self.ldscript}"
if self.entry:
plf_ldflags += f" -m {self.entry}"
@ -646,7 +647,7 @@ def generate_build_ninja(
rels_to_generate = list(
filter(
lambda step: step.module_id != 0
and not step.name in generated_rels,
and step.name not in generated_rels,
link_steps_local,
)
)
@ -714,7 +715,6 @@ def generate_build_ninja(
# Calculate progress
###
n.comment("Calculate progress")
progress_path = build_path / "progress.json"
n.rule(
name="progress",
command=f"$python {configure_script} $configure_args progress",