mirror of
https://github.com/explosion/spaCy.git
synced 2024-12-25 01:16:28 +03:00
Update types and docstrings
This commit is contained in:
parent
e92e850c72
commit
f8846c198d
|
@ -387,8 +387,15 @@ def _from_http_to_git(repo: str) -> str:
|
|||
return repo
|
||||
|
||||
|
||||
def string_to_list(value, intify=False):
|
||||
"""Parse a comma-separated string to a list"""
|
||||
def string_to_list(value: str, intify: bool = False) -> Union[List[str], List[int]]:
|
||||
"""Parse a comma-separated string to a list and account for various
|
||||
formatting options. Mostly used to handle CLI arguments that take a list of
|
||||
comma-separated values.
|
||||
|
||||
value (str): The value to parse.
|
||||
intify (bool): Whether to convert values to ints.
|
||||
RETURNS (Union[List[str], List[int]]): A list of strings or ints.
|
||||
"""
|
||||
if not value:
|
||||
return []
|
||||
if value.startswith("[") and value.endswith("]"):
|
||||
|
|
|
@ -648,12 +648,20 @@ def join_command(command: List[str]) -> str:
|
|||
return " ".join(shlex.quote(cmd) for cmd in command)
|
||||
|
||||
|
||||
def run_command(command: Union[str, List[str]], *, capture=False, stdin=None):
|
||||
def run_command(
|
||||
command: Union[str, List[str]],
|
||||
*,
|
||||
capture: bool = False,
|
||||
stdin: Optional[Any] = None,
|
||||
) -> Optional[subprocess.CompletedProcess]:
|
||||
"""Run a command on the command line as a subprocess. If the subprocess
|
||||
returns a non-zero exit code, a system exit is performed.
|
||||
|
||||
command (str / List[str]): The command. If provided as a string, the
|
||||
string will be split using shlex.split.
|
||||
stdin (Optional[Any]): stdin to read from or None.
|
||||
capture (bool): Whether to capture the output.
|
||||
RETURNS (Optional[CompletedProcess]): The process object.
|
||||
"""
|
||||
if isinstance(command, str):
|
||||
command = split_command(command)
|
||||
|
|
Loading…
Reference in New Issue
Block a user