diff --git a/packages/_dev/boilercv_dev/__main__.py b/packages/_dev/boilercv_dev/__main__.py index 0129d0ee..458195fb 100644 --- a/packages/_dev/boilercv_dev/__main__.py +++ b/packages/_dev/boilercv_dev/__main__.py @@ -6,7 +6,7 @@ from cappa.subcommand import Subcommands -@command(invoke="boilercv_dev.tools.environment._sync_environment_variables") +@command(invoke="boilercv_dev.tools.environment.sync_environment_variables") class SyncEnvironmentVariables: """Sync `.env` with `pyproject.toml`.""" diff --git a/packages/_dev/boilercv_dev/tools/environment.py b/packages/_dev/boilercv_dev/tools/environment.py index 1d1ed41d..7580558c 100644 --- a/packages/_dev/boilercv_dev/tools/environment.py +++ b/packages/_dev/boilercv_dev/tools/environment.py @@ -30,8 +30,12 @@ class Constants(BaseModel): """Shell invocation for running arbitrary commands.""" uv_run_wrapper: str = "./Invoke-Uv.ps1" """Wrapper of `uv run` with extra setup.""" - env: str = ".env" - """Name of environment file.""" + env: Path = ( + Path(environ["GITHUB_ENV"]) + if environ.get("GITHUB_ENV") + else rooted_paths.root / ".env" + ) + """Environment file path.""" pylance_version: str = ( (rooted_paths.root / ".pylance-version").read_text(encoding="utf-8").strip() ) @@ -45,7 +49,7 @@ def sync_environment_variables( path: Path | None = None, pylance_version: str = const.pylance_version, setenv: bool = True, -) -> str: +): """Sync `.env` with `pyproject.toml`, optionally setting environment variables.""" path = Path(path) if path else Path.cwd() / ".env" config_env = Config().env @@ -62,18 +66,8 @@ def sync_environment_variables( dotenv[k] = v if setenv: load_dotenv(stream=StringIO("\n".join(f"{k}={v}" for k, v in dotenv.items()))) - return "\n".join(f"{k}={v}" for k, v in dotenv.items()) - - -def _sync_environment_variables(pylance_version: str = const.pylance_version): - """Sync `.env` with `pyproject.toml`.""" - if environ.get("GITHUB_ENV"): - env = Path(environ["GITHUB_ENV"]) - else: - env = Path.cwd() / ".env" - env.write_text( - encoding="utf-8", - data=sync_environment_variables(pylance_version=pylance_version), + const.env.write_text( + encoding="utf-8", data="\n".join(f"{k}={v}" for k, v in dotenv.items()) ) diff --git a/packages/pipeline/boilercv_pipeline/parser.py b/packages/pipeline/boilercv_pipeline/parser.py index cc56f07c..c53c251b 100644 --- a/packages/pipeline/boilercv_pipeline/parser.py +++ b/packages/pipeline/boilercv_pipeline/parser.py @@ -66,7 +66,7 @@ def invoke( parsed_command, instance, output=concrete_output, - state=state, + state=state, # pyright: ignore[reportCallIssue] deps=deps, ) for dep in global_deps: