|
| 1 | +"""Package metadata accessor for schema version 1.2.2. |
| 2 | +
|
| 3 | +This module provides the metadata accessor for schema version 1.2.2, |
| 4 | +which introduces conda package manager support for Python dependencies. |
| 5 | +All metadata access patterns remain unchanged from v1.2.1, except for |
| 6 | +the new channel field in Python dependencies. |
| 7 | +""" |
| 8 | + |
| 9 | +import logging |
| 10 | +from typing import Dict, Any |
| 11 | +from hatch_validator.core.pkg_accessor_base import HatchPkgAccessor as HatchPkgAccessorBase |
| 12 | + |
| 13 | +logger = logging.getLogger("hatch.package.v1_2_2.accessor") |
| 14 | + |
| 15 | +class HatchPkgAccessor(HatchPkgAccessorBase): |
| 16 | + """Metadata accessor for Hatch package schema version 1.2.2. |
| 17 | +
|
| 18 | + Schema version 1.2.2 introduces conda package manager support for Python |
| 19 | + dependencies with optional channel specification. This accessor implements |
| 20 | + the channel accessor while delegating all other operations to v1.2.1. |
| 21 | + """ |
| 22 | + |
| 23 | + def can_handle(self, schema_version: str) -> bool: |
| 24 | + """Check if this accessor can handle schema version 1.2.2. |
| 25 | +
|
| 26 | + Args: |
| 27 | + schema_version (str): Schema version to check |
| 28 | +
|
| 29 | + Returns: |
| 30 | + bool: True if schema_version is '1.2.2' |
| 31 | + """ |
| 32 | + return schema_version == "1.2.2" |
| 33 | + |
| 34 | + def get_python_dependency_channel(self, dependency: Dict[str, Any]) -> Any: |
| 35 | + """Get channel from a Python dependency. |
| 36 | +
|
| 37 | + This method retrieves the channel field from a Python dependency, |
| 38 | + which is available in schema version 1.2.2 for conda packages. |
| 39 | +
|
| 40 | + Args: |
| 41 | + dependency (Dict[str, Any]): Python dependency object |
| 42 | +
|
| 43 | + Returns: |
| 44 | + Any: Channel value (e.g., "conda-forge", "bioconda"), or None if not specified |
| 45 | + """ |
| 46 | + return dependency.get('channel') |
| 47 | + |
0 commit comments