Skip to content

Commit 4c51094

Browse files
committed
remove unreachable code
1 parent f571fc9 commit 4c51094

File tree

7 files changed

+13
-22
lines changed

7 files changed

+13
-22
lines changed

bin/contest.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import config
22

33
from pathlib import Path
4-
from typing import cast, Any, Optional, TYPE_CHECKING
4+
from typing import cast, Any, Optional, Literal, TYPE_CHECKING
55

66
from util import eprint, error, fatal, log, read_yaml, read_yaml_settings, verbose
77

@@ -25,7 +25,7 @@ def contest_yaml() -> dict[str, Any]:
2525
return _contest_yaml
2626

2727

28-
_problems_yaml = None
28+
_problems_yaml: Literal[False] | Optional[list[dict[str, Any]]] = None
2929

3030

3131
def problems_yaml() -> Optional[list[dict[str, Any]]]:
@@ -45,7 +45,7 @@ def problems_yaml() -> Optional[list[dict[str, Any]]]:
4545
return None
4646
if not isinstance(_problems_yaml, list):
4747
fatal("problems.yaml must contain a list of problems")
48-
return cast(list[dict[str, Any]], _problems_yaml)
48+
return _problems_yaml
4949

5050

5151
def get_api() -> str:

bin/generate.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -806,11 +806,6 @@ def generate(
806806
if t.generator and t.generator.program is None:
807807
bar.done(False, "Generator didn't build. Skipping.")
808808
return
809-
if t.hash is None:
810-
# Input can only be missing when the `copy:` does not have a corresponding `.in` file.
811-
# (When `generate:` or `in:` is used, the input is always present.)
812-
bar.done(False, f"{t.copy} does not exist. Skipping.")
813-
return
814809

815810
target_dir = problem.path / "data" / t.path.parent
816811
target_infile = target_dir / (t.name + ".in")

bin/interactive.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,9 @@ def get_validator_command() -> Sequence[str | Path]:
183183
if not validator_err:
184184
validator_err = bytes()
185185

186-
if not verdict and not run._continue_with_tle(verdict, max_duration >= timeout):
186+
if verdict != Verdict.ACCEPTED and not run._continue_with_tle(
187+
verdict, max_duration >= timeout
188+
):
187189
break
188190

189191
if not run._prepare_nextpass(nextpass):
@@ -488,7 +490,7 @@ def close_io(stream: Optional[IO[bytes]]) -> None:
488490
else:
489491
tle_result.timeout_expired |= aborted
490492

491-
if not verdict and not run._continue_with_tle(verdict, aborted):
493+
if not verdict != Verdict.ACCEPTED and not run._continue_with_tle(verdict, aborted):
492494
break
493495

494496
if not run._prepare_nextpass(nextpass):

bin/problem.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
is_relative_to,
3737
is_uuid,
3838
log,
39+
normalize_yaml_value,
3940
parse_yaml,
4041
PrintBar,
4142
ProgressBar,
@@ -67,14 +68,9 @@ def check_unknown_keys(yaml_data: dict[str, Any], sub_key: Optional[str] = None)
6768

6869
def parse_optional_setting(yaml_data: dict[str, Any], key: str, t: type[T]) -> Optional[T]:
6970
if key in yaml_data:
70-
value = yaml_data.pop(key)
71-
if isinstance(value, int) and t is float:
72-
value = float(value)
71+
value = normalize_yaml_value(yaml_data.pop(key), t)
7372
if isinstance(value, t):
7473
return value
75-
if value == "" and (t is list or t is dict):
76-
# handle empty yaml keys
77-
return t()
7874
warn(f"incompatible value for key '{key}' in problem.yaml. SKIPPED.")
7975
return None
8076

@@ -221,7 +217,7 @@ def source_from_dict(source_dict: dict[str, str]) -> ProblemSource:
221217
self.append(source_from_dict(source))
222218
return
223219
if isinstance(yaml_data["source"], list):
224-
sources = parse_setting(yaml_data, "source", list[dict[str, str]]())
220+
sources = parse_setting(yaml_data, "source", list[Any]())
225221
for i, source in enumerate(sources):
226222
if isinstance(source, str):
227223
self.append(ProblemSource(source))

bin/run.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ def run(
197197
):
198198
self.out_path.unlink()
199199

200-
if result.verdict and (self.feedbackdir / "nextpass.in").is_file():
200+
if result.verdict != Verdict.ACCEPTED and (self.feedbackdir / "nextpass.in").is_file():
201201
assert not self.problem.multi_pass
202202
bar.warn("Validator created nextpass.in for non multi-pass problem. Ignored.")
203203

bin/util.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -267,9 +267,7 @@ def total_width(self) -> int:
267267
cols -= 1
268268
return cols
269269

270-
def bar_width(self) -> Optional[int]:
271-
if self.item_width is None:
272-
return None
270+
def bar_width(self) -> int:
273271
return self.total_width() - len(self.prefix) - 2 - self.item_width
274272

275273
def update(self, count: int, max_len: int) -> None:

bin/verdicts.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ def _print_tree(
498498
printed_text = ["\n\033[2K" * new_lines]
499499
printed_lengths += [0] * new_lines
500500

501-
max_depth = None
501+
max_depth = config.args.depth
502502
show_root = False
503503

504504
stack = [(".", "", "", True)]

0 commit comments

Comments
 (0)