mirror of
https://github.com/explosion/spaCy.git
synced 2025-01-12 10:16:27 +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
|
return repo
|
||||||
|
|
||||||
|
|
||||||
def string_to_list(value, intify=False):
|
def string_to_list(value: str, intify: bool = False) -> Union[List[str], List[int]]:
|
||||||
"""Parse a comma-separated string to a list"""
|
"""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:
|
if not value:
|
||||||
return []
|
return []
|
||||||
if value.startswith("[") and value.endswith("]"):
|
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)
|
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
|
"""Run a command on the command line as a subprocess. If the subprocess
|
||||||
returns a non-zero exit code, a system exit is performed.
|
returns a non-zero exit code, a system exit is performed.
|
||||||
|
|
||||||
command (str / List[str]): The command. If provided as a string, the
|
command (str / List[str]): The command. If provided as a string, the
|
||||||
string will be split using shlex.split.
|
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):
|
if isinstance(command, str):
|
||||||
command = split_command(command)
|
command = split_command(command)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user