Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ select = [
"E9", # pycodestyle: Runtime
"F", # pyflakes
"I", # isort
"UP", # pyupgrade
]
ignore = []

Expand Down
8 changes: 4 additions & 4 deletions run_benchmarks.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
import functools
import os
import timeit
from collections.abc import Callable
from collections.abc import Callable, Iterable
from os import PathLike
from pathlib import Path
from tempfile import TemporaryFile as TempF
from typing import Iterable, Union, cast
from typing import cast

import shapefile

Expand Down Expand Up @@ -51,14 +51,14 @@ def benchmark(
shapeRecords = collections.defaultdict(list)


def open_shapefile_with_PyShp(target: Union[str, PathLike]):
def open_shapefile_with_PyShp(target: str | PathLike):
with shapefile.Reader(target) as r:
fields[target] = r.fields
for shapeRecord in r.iterShapeRecords():
shapeRecords[target].append(shapeRecord)


def write_shapefile_with_PyShp(target: Union[str, PathLike]):
def write_shapefile_with_PyShp(target: str | PathLike):
with TempF("wb") as shp, TempF("wb") as dbf, TempF("wb") as shx:
with shapefile.Writer(shp=shp, dbf=dbf, shx=shx) as w: # type: ignore [arg-type]
for field_info_tuple in fields[target]:
Expand Down
Loading
Loading