mirror of
https://github.com/nix-community/nix-direnv.git
synced 2025-11-08 19:46:11 +01:00
test: use builtins for type annotations instead of List / Optional
This commit is contained in:
parent
26b7fce564
commit
9ac34be48f
2 changed files with 6 additions and 7 deletions
|
|
@ -1,19 +1,19 @@
|
||||||
import subprocess
|
import subprocess
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import IO, Any, List, Optional, Union
|
from typing import IO, Any
|
||||||
|
|
||||||
_FILE = Union[None, int, IO[Any]]
|
_FILE = None | int | IO[Any]
|
||||||
_DIR = Union[None, Path, str]
|
_DIR = None | Path | str
|
||||||
|
|
||||||
|
|
||||||
def run(
|
def run(
|
||||||
cmd: List[str],
|
cmd: list[str],
|
||||||
text: bool = True,
|
text: bool = True,
|
||||||
check: bool = True,
|
check: bool = True,
|
||||||
cwd: _DIR = None,
|
cwd: _DIR = None,
|
||||||
stderr: _FILE = None,
|
stderr: _FILE = None,
|
||||||
stdout: _FILE = None,
|
stdout: _FILE = None,
|
||||||
env: Optional[dict[str, str]] = None,
|
env: dict[str, str] | None = None,
|
||||||
) -> subprocess.CompletedProcess:
|
) -> subprocess.CompletedProcess:
|
||||||
if cwd is not None:
|
if cwd is not None:
|
||||||
print(f"cd {cwd}")
|
print(f"cd {cwd}")
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ import os
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
import unittest
|
import unittest
|
||||||
from typing import Optional
|
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
|
@ -11,7 +10,7 @@ from .procs import run
|
||||||
|
|
||||||
|
|
||||||
def direnv_exec(
|
def direnv_exec(
|
||||||
direnv_project: DirenvProject, cmd: str, env: Optional[dict[str, str]] = None
|
direnv_project: DirenvProject, cmd: str, env: dict[str, str] | None = None
|
||||||
) -> None:
|
) -> None:
|
||||||
args = ["direnv", "exec", str(direnv_project.directory), "sh", "-c", cmd]
|
args = ["direnv", "exec", str(direnv_project.directory), "sh", "-c", cmd]
|
||||||
print("$ " + " ".join(args))
|
print("$ " + " ".join(args))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue