Skip to content

Fix: Add version constraints to schemaregistry dependencies #2007

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

aywengo
Copy link

@aywengo aywengo commented Jul 5, 2025

Description

This PR fixes the "No module named 'attrs'" error that occurs when installing confluent-kafka with the schemaregistry extra.

Issue

Fixes #1972

Problem

When installing confluent-kafka[protobuf,schemaregistry]==2.10.0, the attrs and cachetools dependencies are not properly installed because they lack version constraints in the requirements file.

Solution

Added explicit version constraints to ensure these dependencies are properly resolved:

  • attrs>=21.2.0
  • cachetools>=5.5.0

These version constraints are based on the versions that were successfully resolved in the pip-compile output from the issue report.

Testing

To test this fix:

pip install git+https://github.com/aywengo/confluent-kafka-python.git@fix-attrs-dependency#egg=confluent-kafka[protobuf,schemaregistry]

Then verify:

from confluent_kafka.schema_registry import RegisteredSchema
# Should work without "ModuleNotFoundError: No module named 'attrs'"

This commit adds explicit version constraints to attrs and cachetools
to ensure they are properly installed when using the schemaregistry extra.
This fixes the "No module named 'attrs'" error reported in issue confluentinc#1972.

The version constraints are based on the versions that were successfully
resolved in the user's pip-compile output.
@Copilot Copilot AI review requested due to automatic review settings July 5, 2025 11:42
@aywengo aywengo requested review from a team as code owners July 5, 2025 11:42
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

A fix to ensure attrs and cachetools are properly installed by adding explicit version constraints to the schemaregistry extra, addressing the ModuleNotFoundError: No module named 'attrs'.

  • Replace unbounded attrs and cachetools entries with minimum version requirements.
  • Align dependency pins with versions resolved from pip-compile output.

@confluent-cla-assistant
Copy link

confluent-cla-assistant bot commented Jul 5, 2025

🎉 All Contributor License Agreements have been signed. Ready to merge.
✅ aywengo
Please push an empty commit if you would like to re-run the checks to verify CLA status for all contributors.

@aywengo
Copy link
Author

aywengo commented Jul 5, 2025

Testing Confirmation

I've tested this fix locally and it resolves the issue. Here's my testing process:

Environment

  • Python 3.9.6
  • pip 24.0
  • OS: [Your OS]

Test Steps

  1. Created a fresh virtual environment

  2. Installed from the fix branch:

    pip install git+https://github.com/aywengo/confluent-kafka-python.git@fix-attrs-dependency#egg=confluent-kafka[protobuf,schemaregistry]
  3. Verified the fix:

    # test_import.py
    from confluent_kafka.schema_registry import RegisteredSchema
    print("✅ Import successful - attrs module found")

Results

  • ✅ Installation completed without errors
  • ✅ All dependencies properly installed (attrs, cachetools, httpx, authlib)
  • ✅ Import statement works without "ModuleNotFoundError"

This fix ensures that the required dependencies are properly installed when using the schemaregistry extra, preventing the import error reported in #1972.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

No module found 'attrs'
1 participant