Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/hatch/cli/env/show.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,12 @@ def show(
contextual_config = {}
for environments in (app.project.config.envs, app.project.config.internal_envs):
for env_name, config in environments.items():
environment = app.project.get_environment(env_name)
new_config = contextual_config[env_name] = dict(config)
environment_class = app.project.plugin_manager.environment.get(config["type"])
if environment_class is None:
continue

environment = app.project.get_environment(env_name)

env_vars = dict(environment.env_vars)
env_vars.pop(AppEnvVars.ENV_ACTIVE)
Expand Down
27 changes: 27 additions & 0 deletions tests/cli/env/test_show.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,33 @@ def test_default_as_json(hatch, temp_dir, config_file):
assert environments["default"] == {"type": "virtual"}


def test_default_as_json_unknown_type(hatch, helpers, temp_dir, config_file):
config_file.model.template.plugins["default"]["tests"] = False
config_file.save()

project_name = "My.App"

with temp_dir.as_cwd():
result = hatch("new", project_name)

assert result.exit_code == 0, result.output

project_path = temp_dir / "my-app"
data_path = temp_dir / "data"
data_path.mkdir()

project = Project(project_path)
helpers.update_project_environment(project, "default", {"type": "container"})

with project_path.as_cwd():
result = hatch("env", "show", "--json")

assert result.exit_code == 0, result.output

environments = json.loads(result.output)
assert environments["default"] == {"type": "container"}


def test_single_only(hatch, helpers, temp_dir, config_file):
config_file.model.template.plugins["default"]["tests"] = False
config_file.save()
Expand Down
Loading