Skip to content

Commit be0c3dc

Browse files
committed
commands: reduce reliance on global conf
1 parent 582cf28 commit be0c3dc

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

stagpy/args.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ def compl_cmd() -> None:
109109
return cmd_args.func
110110

111111
if conf.common.config:
112-
commands.config_pp(climan.sections_list(sub_cmd))
112+
commands.config_pp(climan.sections_list(sub_cmd), conf)
113113

114114
_load_mplstyle()
115115

stagpy/commands.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111

1212
import pandas
1313

14-
from . import __version__, conf, phyvars, stagyydata
14+
from . import __version__, phyvars, stagyydata
1515
from ._helpers import baredoc
16-
from .config import CONFIG_LOCAL
16+
from .config import CONFIG_LOCAL, Config
1717

1818
if typing.TYPE_CHECKING:
1919
from typing import Callable, Iterable, Mapping, Optional, Sequence, Tuple, Union
@@ -29,6 +29,8 @@ def info_cmd() -> None:
2929
Other Parameters:
3030
conf.info
3131
"""
32+
from . import conf
33+
3234
sdat = stagyydata.StagyyData(conf.core.path)
3335
lsnap = sdat.snaps[-1]
3436
lstep = sdat.steps[-1]
@@ -138,6 +140,8 @@ def var_cmd() -> None:
138140
See :mod:`stagpy.phyvars` where the lists of variables organized by command
139141
are defined.
140142
"""
143+
from . import conf
144+
141145
print_all = not any(getattr(conf.var, fld.name) for fld in fields(conf.var))
142146
if print_all or conf.var.field:
143147
print("field:")
@@ -169,7 +173,7 @@ def version_cmd() -> None:
169173
print(f"stagpy version: {__version__}")
170174

171175

172-
def config_pp(subs: Iterable[str]) -> None:
176+
def config_pp(subs: Iterable[str], conf: Config) -> None:
173177
"""Pretty print of configuration options.
174178
175179
Args:
@@ -199,7 +203,9 @@ def config_cmd() -> None:
199203
Other Parameters:
200204
conf.config
201205
"""
206+
from . import conf
207+
202208
if conf.config.create:
203209
conf.default_().to_file_(CONFIG_LOCAL)
204210
else:
205-
config_pp(sec.name for sec in fields(conf))
211+
config_pp((sec.name for sec in fields(conf)), conf)

0 commit comments

Comments
 (0)