Skip to content

Commit dbd825a

Browse files
committed
Bump to minimum Python version to 3.10
1 parent b8a5c50 commit dbd825a

15 files changed

+41
-678
lines changed

.pre-commit-config.yaml

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,22 @@ fail_fast: true
22

33
repos:
44
- repo: https://github.com/pre-commit/pre-commit-hooks
5-
rev: v4.4.0
5+
rev: v6.0.0
66
hooks:
77
- id: debug-statements
88
id: trailing-whitespace
99
id: end-of-file-fixer
1010

11-
- repo: https://github.com/psf/black
12-
rev: 23.3.0
13-
hooks:
14-
- id: black
15-
1611
- repo: https://github.com/charliermarsh/ruff-pre-commit
17-
rev: 'v0.0.261'
12+
rev: 'v0.12.8'
1813
hooks:
1914
- id: ruff
15+
types_or: [ python, pyi, jupyter ]
2016
args: [--fix]
17+
- id: ruff-format
18+
types_or: [ python, pyi, jupyter ]
2119

2220
- repo: https://github.com/pre-commit/mirrors-mypy
23-
rev: v1.2.0
21+
rev: v1.17.1
2422
hooks:
2523
- id: mypy

poetry.lock

Lines changed: 0 additions & 621 deletions
This file was deleted.

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ classifiers = [
1919
"Topic :: Scientific/Engineering",
2020
"Programming Language :: Python :: 3",
2121
]
22-
requires-python = ">=3.9"
22+
requires-python = ">=3.10"
2323
dependencies = [
2424
"numpy>=1.19.3; python_version < '3.12'",
2525
"numpy>=1.26.0; python_version >= '3.12'",
@@ -48,7 +48,7 @@ line-length = 79
4848

4949
[tool.ruff.lint]
5050
select = [
51-
"E", "F", "I", "NPY", "PYI", "Q", "RET", "RSE", "RUF", "SLF", "SIM", "TC"
51+
"E", "F", "I", "NPY", "PYI", "Q", "RET", "RSE", "RUF", "SLF", "SIM", "TC",
5252
]
5353

5454

vrplib/download/download_instance.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
import os
22
import warnings
33
from pathlib import Path
4-
from typing import Union
54
from urllib.request import urlopen
65

76
from .constants import CVRPLIB_URL
87
from .download_utils import find_set, is_vrptw
98

109

11-
def download_instance(name: str, path: Union[str, os.PathLike]):
10+
def download_instance(name: str, path: str | os.PathLike):
1211
"""
1312
Downloads an instance file from CVRPLIB and saves it at the specified path.
1413

vrplib/download/download_solution.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
import os
22
import warnings
33
from pathlib import Path
4-
from typing import Union
54
from urllib.request import urlopen
65

76
from .constants import CVRPLIB_URL
87
from .download_utils import find_set
98

109

11-
def download_solution(name: str, path: Union[str, os.PathLike]):
10+
def download_solution(name: str, path: str | os.PathLike):
1211
"""
1312
Downloads a solution file from CVRPLIB and saves it at the specified path.
1413

vrplib/download/list_names.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
import importlib.resources as pkg_resource
22
import warnings
33
from functools import lru_cache
4-
from typing import Optional
54

65
from .download_utils import is_vrptw
76

87

98
def list_names(
10-
low: Optional[int] = None,
11-
high: Optional[int] = None,
12-
vrp_type: Optional[str] = None,
9+
low: int | None = None,
10+
high: int | None = None,
11+
vrp_type: str | None = None,
1312
):
1413
"""
1514
Returns the names of the instances that can be downloaded from CVRPLIB.
@@ -40,7 +39,7 @@ def list_names(
4039
if vrp_type not in [None, "cvrp", "vrptw"]:
4140
raise ValueError("vrp_type must be one of [None, 'cvrp', 'vrptw']")
4241

43-
elif vrp_type == "cvrp":
42+
if vrp_type == "cvrp":
4443
instances = filter(lambda inst: not is_vrptw(inst["name"]), instances)
4544

4645
elif vrp_type == "vrptw":

vrplib/parse/parse_distances.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
from itertools import combinations
2-
from typing import Optional, Union
32

43
import numpy as np
54

65

76
def parse_distances(
87
data: list[float],
98
edge_weight_type: str,
10-
edge_weight_format: Optional[str] = None,
11-
node_coord: Optional[np.ndarray] = None,
12-
comment: Optional[str] = None,
13-
**kwargs: Union[float, str, np.ndarray], # noqa
9+
edge_weight_format: str | None = None,
10+
node_coord: np.ndarray | None = None,
11+
comment: str | None = None,
12+
**kwargs: float | str | np.ndarray,
1413
) -> np.ndarray:
1514
"""
1615
Parses the distances. The specification "edge_weight_type" describes how
@@ -63,8 +62,7 @@ def parse_distances(
6362
# (C)VRPLIB format. Find a better way to identify Eilon instances.
6463
if comment is not None and "Eilon" in comment:
6564
return from_eilon(data)
66-
else:
67-
return from_lower_row(data)
65+
return from_lower_row(data)
6866

6967
if edge_weight_format == "FULL_MATRIX":
7068
return np.array(data)

vrplib/parse/parse_solomon.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
from typing import Union
2-
31
import numpy as np
42

53
from .parse_distances import pairwise_euclidean
64
from .parse_utils import text2lines
75

8-
Instance = dict[str, Union[str, float, np.ndarray]]
6+
Instance = dict[str, str | float | np.ndarray]
97

108

119
def parse_solomon(text: str, compute_edge_weights: bool = True) -> Instance:

vrplib/parse/parse_solution.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
from typing import Union
2-
31
from .parse_utils import infer_type, text2lines
42

5-
Solution = dict[str, Union[float, str, list]]
3+
Solution = dict[str, float | str | list]
64

75

86
def parse_solution(text: str) -> Solution:

vrplib/parse/parse_utils.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
from typing import Union
2-
3-
41
def text2lines(text: str) -> list[str]:
52
"""
63
Takes a string and returns a list of non-empty, stripped lines. Also
@@ -13,7 +10,7 @@ def text2lines(text: str) -> list[str]:
1310
]
1411

1512

16-
def infer_type(s: str) -> Union[int, float, str]:
13+
def infer_type(s: str) -> int | float | str:
1714
try:
1815
return int(s)
1916
except ValueError:

0 commit comments

Comments
 (0)