Skip to content

Commit 6942cea

Browse files
committed
config: expose typing aliases for autodoc
1 parent d25f6f5 commit 6942cea

File tree

3 files changed

+12
-22
lines changed

3 files changed

+12
-22
lines changed

src/vcspull/_internal/config_reader.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,8 @@
77

88
import yaml
99

10-
if t.TYPE_CHECKING:
11-
from typing import Literal, TypeAlias
12-
13-
FormatLiteral = Literal["json", "yaml"]
14-
15-
RawConfigData: TypeAlias = dict[t.Any, t.Any]
10+
FormatLiteral = t.Literal["json", "yaml"]
11+
RawConfigData: t.TypeAlias = dict[t.Any, t.Any]
1612

1713

1814
class ConfigReader:

src/vcspull/config.py

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import logging
88
import os
99
import pathlib
10+
from collections.abc import Callable
1011
import typing as t
1112

1213
from libvcs.sync.git import GitRemote
@@ -16,15 +17,10 @@
1617
from . import exc
1718
from ._internal.config_reader import ConfigReader, DuplicateAwareConfigReader
1819
from .util import get_config_dir, update_dict
20+
from .types import ConfigDict, RawConfigDict
1921

2022
log = logging.getLogger(__name__)
2123

22-
if t.TYPE_CHECKING:
23-
from collections.abc import Callable
24-
from typing import TypeGuard
25-
26-
from .types import ConfigDict, RawConfigDict
27-
2824

2925
def expand_dir(
3026
dir_: pathlib.Path,
@@ -34,14 +30,15 @@ def expand_dir(
3430
3531
Parameters
3632
----------
37-
_dir : pathlib.Path
33+
dir_ : pathlib.Path
34+
Directory path to expand
3835
cwd : pathlib.Path, optional
39-
current working dir (for deciphering relative _dir paths), defaults to
40-
:py:meth:`os.getcwd()`
36+
Current working dir (used to resolve relative paths). Defaults to
37+
:py:meth:`pathlib.Path.cwd`.
4138
4239
Returns
4340
-------
44-
pathlib.Path :
41+
pathlib.Path
4542
Absolute directory path
4643
"""
4744
dir_ = pathlib.Path(os.path.expandvars(str(dir_))).expanduser()
@@ -136,7 +133,7 @@ def extract_repos(
136133
**url,
137134
)
138135

139-
def is_valid_config_dict(val: t.Any) -> TypeGuard[ConfigDict]:
136+
def is_valid_config_dict(val: t.Any) -> t.TypeGuard[ConfigDict]:
140137
assert isinstance(val, dict)
141138
return True
142139

src/vcspull/validator.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,10 @@
55
import pathlib
66
import typing as t
77

8-
if t.TYPE_CHECKING:
9-
from typing import TypeGuard
8+
from vcspull.types import RawConfigDict
109

11-
from vcspull.types import RawConfigDict
1210

13-
14-
def is_valid_config(config: dict[str, t.Any]) -> TypeGuard[RawConfigDict]:
11+
def is_valid_config(config: dict[str, t.Any]) -> t.TypeGuard[RawConfigDict]:
1512
"""Return true and upcast if vcspull configuration file is valid."""
1613
if not isinstance(config, dict):
1714
return False

0 commit comments

Comments
 (0)