Skip to content

Commit ad34218

Browse files
committed
use class method properly
1 parent 7d1eccf commit ad34218

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

bin/stats.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ def get_submissions_row(
380380
values = []
381381
for problem in problems:
382382
directory = (
383-
Path().cwd() / "submissions" / problem.name
383+
Path.cwd() / "submissions" / problem.name
384384
if team_submissions
385385
else problem.path / "submissions"
386386
)

bin/tools.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ def change_directory() -> Optional[Path]:
8888
if config.args.problem:
8989
# TODO #102: replace cast with typed Namespace field
9090
problem_dir = cast(Path, config.args.problem).absolute()
91-
elif is_problem_directory(Path().cwd()):
92-
problem_dir = Path().cwd().absolute()
91+
elif is_problem_directory(Path.cwd()):
92+
problem_dir = Path.cwd().absolute()
9393
if problem_dir is not None:
9494
config.level = "problem"
9595
os.chdir(problem_dir.parent)
@@ -101,7 +101,7 @@ def change_directory() -> Optional[Path]:
101101
# or check the existence of problem.yaml and sort by shortname.
102102
def get_problems(problem_dir: Optional[Path]) -> tuple[list[Problem], Path]:
103103
# We create one tmpdir per contest.
104-
h = hashlib.sha256(bytes(Path().cwd())).hexdigest()[-6:]
104+
h = hashlib.sha256(bytes(Path.cwd())).hexdigest()[-6:]
105105
tmpdir = Path(tempfile.gettempdir()) / ("bapctools_" + h)
106106
tmpdir.mkdir(parents=True, exist_ok=True)
107107

@@ -1022,7 +1022,7 @@ def read_personal_config(problem_dir: Optional[Path]) -> dict[str, Any]:
10221022
config_files = []
10231023
if problem_dir:
10241024
config_files.append(problem_dir / ".bapctools.yaml")
1025-
config_files.append(Path().cwd() / ".bapctools.yaml")
1025+
config_files.append(Path.cwd() / ".bapctools.yaml")
10261026
if home_config:
10271027
config_files.append(home_config / "bapctools" / "config.yaml")
10281028

@@ -1047,10 +1047,10 @@ def run_parsed_arguments(args: argparse.Namespace, personal_config: bool = True)
10471047
missing_args = config.set_default_args()
10481048

10491049
# cd to contest directory
1050-
call_cwd = Path().cwd().absolute()
1050+
call_cwd = Path.cwd().absolute()
10511051
problem_dir = change_directory()
10521052
level = config.level
1053-
contest_name = Path().cwd().name
1053+
contest_name = Path.cwd().name
10541054

10551055
if personal_config:
10561056
personal_args = read_personal_config(problem_dir)
@@ -1443,7 +1443,7 @@ def test(args: list[str]) -> None:
14431443

14441444
# Make sure to cd back to the original directory before returning.
14451445
# Needed to stay in the same directory in tests.
1446-
original_directory = Path().cwd()
1446+
original_directory = Path.cwd()
14471447
config.n_warn = 0
14481448
config.n_error = 0
14491449
contest._contest_yaml = None

bin/upgrade.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -622,7 +622,7 @@ def upgrade(problem_dir: Optional[Path]) -> None:
622622
bar = ProgressBar("upgrade", items=paths)
623623
else:
624624
assert config.level == "problemset"
625-
contest_dir = Path().cwd()
625+
contest_dir = Path.cwd()
626626
paths = [p for p in contest_dir.iterdir() if is_problem_directory(p)]
627627
bar = ProgressBar("upgrade", items=["contest.yaml", *paths])
628628

0 commit comments

Comments
 (0)