Skip to content

Commit

Permalink
Properly support applications (#1370)
Browse files Browse the repository at this point in the history
  • Loading branch information
ofek authored Apr 5, 2024
1 parent 35ed84a commit f8c1927
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
1 change: 1 addition & 0 deletions docs/history/hatch.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
***Fixed:***

- When projects derive dependencies from metadata hooks, there is now by default a status indicator for when the hooks are executed for better responsiveness
- Properly support projects with a `pyproject.toml` file but no `project` table e.g. applications
- Fix dependency inheritance for the template of the `types` environment for new projects

## [1.9.4](https://github.com/pypa/hatch/releases/tag/hatch-v1.9.4) - 2024-03-12 ## {: #hatch-v1.9.4 }
Expand Down
7 changes: 6 additions & 1 deletion src/hatch/project/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,12 @@ def raw_config(self):
else:
from hatch.utils.toml import load_toml_file

self._raw_config = load_toml_file(str(self._project_file_path))
raw_config = load_toml_file(str(self._project_file_path))
# Assume environment management only
if 'project' not in raw_config:
raw_config['project'] = {'name': self.location.name}

self._raw_config = raw_config

return self._raw_config

Expand Down
27 changes: 27 additions & 0 deletions tests/project/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,30 @@ def test_project(self, temp_dir, file_name):
project = Project(temp_dir)
assert project.location == temp_dir
assert project.root == temp_dir


class TestRawConfig:
def test_missing(self, temp_dir):
project = Project(temp_dir)
project.find_project_root()

assert project.raw_config == {'project': {'name': temp_dir.name}}

def test_exists(self, temp_dir):
project_file = temp_dir / 'pyproject.toml'
project_file.touch()
project = Project(temp_dir)
project.find_project_root()

config = {'project': {'name': 'foo'}, 'bar': 'baz'}
project.save_config(config)

assert project.raw_config == config

def test_exists_without_project_table(self, temp_dir):
project_file = temp_dir / 'pyproject.toml'
project_file.touch()
project = Project(temp_dir)
project.find_project_root()

assert project.raw_config == {'project': {'name': temp_dir.name}}

0 comments on commit f8c1927

Please sign in to comment.