Skip to content

Commit ea3357f

Browse files
feat: expand variables and user dirs in settings of type Path. (#83)
<!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Automatically expands user home (~) and environment variables in plugin path settings before use, ensuring resolved, usable paths. * Applies to all Path-based configuration values during settings extraction for consistent behavior across environments. * Reduces manual configuration by accepting shorthand and environment-based paths in plugin configuration. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent f641114 commit ea3357f

File tree

1 file changed

+6
-0
lines changed
  • src/snakemake_interface_common/plugin_registry

1 file changed

+6
-0
lines changed

src/snakemake_interface_common/plugin_registry/plugin.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from collections import defaultdict
88
from dataclasses import field, fields, Field
99
from dataclasses import MISSING, dataclass
10+
import os
1011
from pathlib import Path
1112
from typing import (
1213
Any,
@@ -273,6 +274,11 @@ def extract_values(
273274
)
274275
elif thefield.type != str and isinstance(thefield.type, type):
275276
value = self._parse_type(thefield, value, thefield.type)
277+
278+
# expand variables and user dirs in paths
279+
if isinstance(value, Path):
280+
value = Path(os.path.expandvars(str(value.expanduser())))
281+
276282
if tag is None:
277283
kwargs_all[name] = value
278284
else:

0 commit comments

Comments
 (0)