Skip to content

0.23.0: AttributeError: 'CondaRequirement' object has no attribute 'channel' in _iter_parts #94

@drbenvincent

Description

@drbenvincent

Summary

pyproject2conda 0.23.0 (published to PyPI on 2026-04-29) raises AttributeError immediately when materialising any conda requirement. 0.22.1 works correctly with the same input.

Reproduction

pyproject.toml declares conda dependencies via dependency-groups/extras and we invoke:

pyproject2conda yaml -e dev -o /tmp/environment.generated.yml -n CausalPy \
  -w force --no-header \
  --python-include 'python>=3.12' \
  -d make -d pip -d pymc-bart -r 'marimo[mcp]'

This succeeds on 0.22.1 and fails on 0.23.0 with:

File ".../pyproject2conda/_normalized_requirements.py", line 115, in _iter_parts
    if self.channel:
       ^^^^^^^^^^^^
AttributeError: 'CondaRequirement' object has no attribute 'channel'

The traceback shows _iter_parts being reached via CondaRequirement.__hash__, so any code path that hashes a CondaRequirement (e.g. inserting into a set/dict during dependency aggregation) triggers it.

Likely cause

0.23.0 reworks validation onto pydantic (#92, "feat!: Use pydantic for validation"). It looks like the channel field was dropped or renamed on CondaRequirement during that migration, but _iter_parts in _normalized_requirements.py still reads self.channel unconditionally. Either the attribute should be restored (with a sensible default of None/empty), or _iter_parts should be updated to read the new field.

Environment

  • Python 3.12 (Ubuntu, GitHub Actions ubuntu-latest).
  • Installed via pip install pyproject2conda (resolves to 0.23.0).
  • Same inputs work on 0.22.1.

Workaround

Downstream users can pin pyproject2conda<0.23 until this is resolved. Reporting from CausalPy (https://github.com/pymc-labs/CausalPy), where every PR opened since 2026-04-29 has had its check-environment-yml job fail. Tracked downstream in pymc-labs/CausalPy#878.

Happy to test a fix or provide a fuller minimal reproducer if useful — just let me know.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions