- Replace Optional[X] with X | None (UP045) - Replace typing.List/Dict/Set/Tuple with built-in list/dict/set/tuple (UP006, UP035) - Replace typing.Deque with collections.deque (UP035) - Import Sequence/Iterable from collections.abc instead of typing (UP035) - Remove unused typing imports (F401) - Update datetime.timezone.utc to datetime.UTC (UP017) - Organize imports with isort (I001) Files updated: - sources/table_scraper.py - sources/brands_json_to_csv.py - scripts/extract/raw_datasets.py - scripts/generate_sources_table.py - scripts/update_changelog.py - scripts/update_repo.py - scripts/validate/csv_validator.py - tests/conftest.py - tests/test_dimensions.py - tests/test_schema_validation.py - tests/test_table_scraper.py Co-authored-by: ArtemFilin1990 <221041513+ArtemFilin1990@users.noreply.github.com>
19 lines
676 B
Python
19 lines
676 B
Python
import csv
|
|
from pathlib import Path
|
|
|
|
|
|
def _load_dimensions(path: Path) -> list[tuple[str, float, float, float]]:
|
|
with path.open(encoding="utf-8") as handle:
|
|
reader = csv.DictReader(handle)
|
|
return [(row["designation"], float(row["d"]), float(row["D"]), float(row["B"])) for row in reader]
|
|
|
|
|
|
def test_gost_dimensions_sorted() -> None:
|
|
rows = _load_dimensions(Path("data/gost/dimensions.csv"))
|
|
assert rows == sorted(rows, key=lambda item: (item[0], item[1], item[2]))
|
|
|
|
|
|
def test_iso_dimensions_sorted() -> None:
|
|
rows = _load_dimensions(Path("data/iso/dimensions.csv"))
|
|
assert rows == sorted(rows, key=lambda item: (item[0], item[1], item[2]))
|