Skip to content

Commit f7e8abf

Browse files
author
LittleCoinCoin
committed
fix: hatch package validation
The implementation was still relying on a much older hatch version. Now we are validating the exact same way Hatch is: directly instantiating the validator **Minor**: we are also upgrading the version of Hatch from `0.5.1` to `0.6.1` This new version leverages `hatch-validator` version `0.7.0` which supports checking the new dual-entry file information about the MCP server (the FastMCP implementation + the HatchMCP wrapper)
1 parent 99625a4 commit f7e8abf

File tree

2 files changed

+19
-7
lines changed

2 files changed

+19
-7
lines changed

hatchling/ui/hatch_commands.py

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -782,18 +782,30 @@ def _cmd_validate_package(self, args: str) -> bool:
782782
try:
783783
package_path = Path(parsed_args['package_dir']).resolve()
784784

785-
# Use the validator from environment manager
786-
is_valid, validation_results = mcp_manager.hatch_env_manager.package_validator.validate_package(package_path)
785+
# Create validator with registry data from environment manager
786+
from hatch_validator import HatchPackageValidator
787+
validator = HatchPackageValidator(
788+
version="latest",
789+
allow_local_dependencies=True,
790+
registry_data=mcp_manager.hatch_env_manager.registry_data
791+
)
792+
793+
# Validate the package
794+
is_valid, validation_results = validator.validate_package(package_path)
787795

788796
if is_valid:
789797
self.logger.info(f"Package validation SUCCESSFUL: {package_path}")
790798
else:
791799
self.logger.warning(f"Package validation FAILED: {package_path}")
800+
801+
# Print detailed validation results if available
792802
if validation_results and isinstance(validation_results, dict):
793-
for key, issues in validation_results.items():
794-
self.logger.warning(f"\n{key} issues:")
795-
for issue in issues:
796-
self.logger.warning(f"- {issue}")
803+
for category, result in validation_results.items():
804+
if category != 'valid' and category != 'metadata' and isinstance(result, dict):
805+
if not result.get('valid', True) and result.get('errors'):
806+
self.logger.warning(f"\n{category.replace('_', ' ').title()} errors:")
807+
for error in result['errors']:
808+
self.logger.warning(f" - {error}")
797809

798810
except Exception as e:
799811
self.logger.error(f"Error validating package: {e}")

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ dependencies = [
3737
"ollama==0.5.1",
3838
"openai==1.97.0",
3939

40-
"hatch @ git+https://github.com/CrackingShells/Hatch.git@v0.5.1"
40+
"hatch @ git+https://github.com/CrackingShells/Hatch.git@v0.6.1"
4141
]
4242

4343
[project.scripts]

0 commit comments

Comments
 (0)