use Path in type annotations

This commit is contained in:
Justus Kuhlmann 2026-03-23 13:05:33 +01:00
commit 92f307b83a
Signed by: jkuhl
GPG key ID: 00ED992DD79B85A6
4 changed files with 11 additions and 9 deletions

View file

@ -1,7 +1,7 @@
import corrlib.toml as t import corrlib.toml as t
def test_toml_check_measurement_data(): def test_toml_check_measurement_data() -> None:
measurements = { measurements = {
"a": "a":
{ {

View file

@ -1,7 +1,7 @@
import corrlib.input.sfcf as input import corrlib.input.sfcf as input
import json import json
def test_get_specs(): def test_get_specs() -> None:
parameters = { parameters = {
'crr': [ 'crr': [
'f_P', 'f_A' 'f_P', 'f_A'

View file

@ -1,22 +1,23 @@
import corrlib.initialization as init import corrlib.initialization as init
import os import os
import sqlite3 as sql import sqlite3 as sql
from pathlib import Path
def test_init_folders(tmp_path): def test_init_folders(tmp_path: Path) -> None:
dataset_path = tmp_path / "test_dataset" dataset_path = tmp_path / "test_dataset"
init.create(str(dataset_path)) init.create(str(dataset_path))
assert os.path.exists(str(dataset_path)) assert os.path.exists(str(dataset_path))
assert os.path.exists(str(dataset_path / "backlogger.db")) assert os.path.exists(str(dataset_path / "backlogger.db"))
def test_init_folders_no_tracker(tmp_path): def test_init_folders_no_tracker(tmp_path: Path) -> None:
dataset_path = tmp_path / "test_dataset" dataset_path = tmp_path / "test_dataset"
init.create(str(dataset_path), tracker="None") init.create(str(dataset_path), tracker="None")
assert os.path.exists(str(dataset_path)) assert os.path.exists(str(dataset_path))
assert os.path.exists(str(dataset_path / "backlogger.db")) assert os.path.exists(str(dataset_path / "backlogger.db"))
def test_init_config(tmp_path): def test_init_config(tmp_path: Path) -> None:
dataset_path = tmp_path / "test_dataset" dataset_path = tmp_path / "test_dataset"
init.create(str(dataset_path), tracker="None") init.create(str(dataset_path), tracker="None")
config_path = dataset_path / ".corrlib" config_path = dataset_path / ".corrlib"
@ -34,7 +35,7 @@ def test_init_config(tmp_path):
assert config.get("paths", "import_scripts_path") == "import_scripts" assert config.get("paths", "import_scripts_path") == "import_scripts"
def test_init_db(tmp_path): def test_init_db(tmp_path: Path) -> None:
dataset_path = tmp_path / "test_dataset" dataset_path = tmp_path / "test_dataset"
init.create(str(dataset_path)) init.create(str(dataset_path))
assert os.path.exists(str(dataset_path / "backlogger.db")) assert os.path.exists(str(dataset_path / "backlogger.db"))

View file

@ -1,6 +1,7 @@
from corrlib import tools as tl from corrlib import tools as tl
from configparser import ConfigParser from configparser import ConfigParser
import os import os
from pathlib import Path
def test_m2k() -> None: def test_m2k() -> None:
@ -31,7 +32,7 @@ def test_list2str() -> None:
assert tl.list2str(["1", "2", "3"]) == "1,2,3" assert tl.list2str(["1", "2", "3"]) == "1,2,3"
def test_set_config(tmp_path: str) -> None: def test_set_config(tmp_path: Path) -> None:
section = "core" section = "core"
option = "test_option" option = "test_option"
value = "test_value" value = "test_value"
@ -61,7 +62,7 @@ def test_set_config(tmp_path: str) -> None:
assert config.get('core', 'test_option2', fallback="not the value") == "test_value3" assert config.get('core', 'test_option2', fallback="not the value") == "test_value3"
def test_get_db_file(tmp_path: str) -> None: def test_get_db_file(tmp_path: Path) -> None:
section = "paths" section = "paths"
option = "db" option = "db"
value = "test_value" value = "test_value"
@ -70,7 +71,7 @@ def test_get_db_file(tmp_path: str) -> None:
assert tl.get_db_file(tmp_path) == "test_value" assert tl.get_db_file(tmp_path) == "test_value"
def test_cache_enabled(tmp_path: str) -> None: def test_cache_enabled(tmp_path: Path) -> None:
section = "core" section = "core"
option = "cached" option = "cached"
value = "True" value = "True"