Skip to content

Commit 0388c39

Browse files
committed
Bump loam version to 0.5.2
1 parent 065e7f7 commit 0388c39

File tree

2 files changed

+4
-31
lines changed

2 files changed

+4
-31
lines changed

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ include_package_data = true
2929
packages =
3030
stagpy
3131
install_requires =
32-
loam>=0.5.0,<0.6.0
32+
loam>=0.5.2,<0.6.0
3333
f90nml>=1.3.1
3434
setuptools_scm>=6.3.2
3535
numpy>=1.19

stagpy/config.py

Lines changed: 3 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -6,42 +6,15 @@
66

77
from __future__ import annotations
88
import pathlib
9-
import typing
109

1110
from loam.manager import ConfOpt as Conf
1211
from loam import tools
1312
from loam.tools import switch_opt, command_flag
13+
import loam.types
1414

15-
if typing.TYPE_CHECKING:
16-
from typing import Union, Callable, TypeVar, Tuple
17-
T = TypeVar('T')
1815

19-
20-
def _slice_or_int(arg: str) -> Union[slice, int]:
21-
"""Parse a string into an integer or slice."""
22-
if ':' in arg:
23-
idxs = arg.split(':')
24-
if len(idxs) > 3:
25-
raise ValueError(f'{arg} is an invalid slice')
26-
slice_parts = [int(idxs[0]) if idxs[0] else None,
27-
int(idxs[1]) if idxs[1] else None]
28-
if len(idxs) == 3:
29-
slice_parts.append(int(idxs[2]) if idxs[2] else None)
30-
else:
31-
slice_parts.append(1)
32-
return slice(*slice_parts)
33-
return int(arg)
34-
35-
36-
def _list_of(from_str: Callable[[str], T]) -> Callable[[str], Tuple[T, ...]]:
37-
"""Return fn parsing a str as a comma-separated list of given type."""
38-
def parser(arg: str) -> Tuple[T, ...]:
39-
return tuple(from_str(v) for v in map(str.strip, arg.split(',')) if v)
40-
return parser
41-
42-
43-
_index_collection = _list_of(_slice_or_int)
44-
_float_list = _list_of(float)
16+
_index_collection = loam.types.list_of(loam.types.slice_or_int_parser)
17+
_float_list = loam.types.list_of(float)
4518

4619
HOME_DIR = pathlib.Path.home()
4720
CONFIG_DIR = HOME_DIR / '.config' / 'stagpy'

0 commit comments

Comments
 (0)