Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions .semaphore/semaphore.yml
Original file line number Diff line number Diff line change
Expand Up @@ -196,14 +196,14 @@ blocks:
jobs:
- name: Build and Tests with 'classic' group protocol
commands:
- sem-version python 3.9
- sem-version python 3.11
# use a virtualenv
- python3 -m venv _venv && source _venv/bin/activate
- chmod u+r+x tools/source-package-verification.sh
- tools/source-package-verification.sh
- name: Build and Tests with 'consumer' group protocol
commands:
- sem-version python 3.9
- sem-version python 3.11
- sem-version java 17
# use a virtualenv
- python3 -m venv _venv && source _venv/bin/activate
Expand All @@ -212,7 +212,7 @@ blocks:
- tools/source-package-verification.sh
- name: Build, Test, and Report coverage
commands:
- sem-version python 3.9
- sem-version python 3.11
# use a virtualenv
- python3 -m venv _venv && source _venv/bin/activate
- chmod u+r+x tools/source-package-verification.sh
Expand All @@ -236,7 +236,7 @@ blocks:
jobs:
- name: Build
commands:
- sem-version python 3.9
- sem-version python 3.11
# use a virtualenv
- python3 -m venv _venv && source _venv/bin/activate
- chmod u+r+x tools/source-package-verification.sh
Expand All @@ -255,7 +255,7 @@ blocks:
jobs:
- name: Build
commands:
- sem-version python 3.9
- sem-version python 3.11
# use a virtualenv
- python3 -m venv _venv && source _venv/bin/activate
- chmod u+r+x tools/source-package-verification.sh
Expand All @@ -274,7 +274,7 @@ blocks:
jobs:
- name: Build
commands:
- sem-version python 3.9
- sem-version python 3.11
# use a virtualenv
- python3 -m venv _venv && source _venv/bin/activate
- chmod u+r+x tools/source-package-verification.sh
Expand All @@ -301,7 +301,7 @@ blocks:
- name: Build and Tests
commands:
# Setup Python environment
- sem-version python 3.9
- sem-version python 3.11
- python3 -m venv _venv && source _venv/bin/activate

# Install ducktape framework and additional dependencies
Expand Down
4 changes: 3 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
include README.md
include LICENSE
include src/confluent_kafka/src/*.[ch]
include src/confluent_kafka/py.typed
include src/confluent_kafka/cimpl.pyi
prune tests
prune docs
prune docs
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ all:
@echo "Targets:"
@echo " clean"
@echo " docs"
@echo " mypy"
@echo " style-check"
@echo " style-fix"


clean:
Expand All @@ -14,6 +17,9 @@ clean:
docs:
$(MAKE) -C docs html

mypy:
python3 -m mypy src/confluent_kafka

style-check:
@(tools/style-format.sh \
$$(git ls-tree -r --name-only HEAD | egrep '\.(c|h|py)$$') )
Expand Down
2 changes: 1 addition & 1 deletion requirements/requirements-avro.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
fastavro < 1.8.0; python_version == "3.7"
fastavro < 2; python_version > "3.7"
requests
avro>=1.11.1,<2
avro>=1.11.1,<2
1 change: 1 addition & 0 deletions requirements/requirements-tests.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ urllib3<3
flake8
mypy
types-cachetools
types-requests
orjson
pytest
pytest-timeout
Expand Down
6 changes: 5 additions & 1 deletion src/confluent_kafka/deserializing_consumer.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,11 @@ def poll(self, timeout: float = -1) -> Optional[Message]:
if error is not None:
raise ConsumeError(error, kafka_message=msg)

ctx = SerializationContext(msg.topic(), MessageField.VALUE, msg.headers())
topic = msg.topic()
if topic is None:
raise TypeError("Message topic is None")
ctx = SerializationContext(topic, MessageField.VALUE, msg.headers())

value = msg.value()
if self._value_deserializer is not None:
try:
Expand Down
5 changes: 5 additions & 0 deletions tools/source-package-verification.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#
set -e

pip install --upgrade pip
pip install -r requirements/requirements-tests-install.txt
pip install -U build

Expand Down Expand Up @@ -51,6 +52,10 @@ if [[ $OS_NAME == linux && $ARCH == x64 ]]; then
# Run these actions and tests only in this case
echo "Building documentation ..."
flake8 --exclude ./_venv,*_pb2.py,./build

echo "Running mypy type checking ..."
python3.11 -m mypy src/confluent_kafka

pip install -r requirements/requirements-docs.txt
make docs

Expand Down
9 changes: 8 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist = flake8,py37,py38,py39,py310,py311,py312,py313
envlist = flake8,mypy,py37,py38,py39,py310,py311,py312,py313

[testenv]
passenv =
Expand All @@ -20,6 +20,13 @@ commands =
deps = flake8
commands = flake8

[testenv:mypy]
deps =
mypy
types-cachetools
types-requests~=2.32.0
commands = mypy src/confluent_kafka
Copy link

Copilot AI Nov 6, 2025

Choose a reason for hiding this comment

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

The mypy command should include the --strict or explicit configuration flags (e.g., --disallow-untyped-defs, --warn-return-any) to ensure consistent type checking behavior. Without explicit flags, mypy's behavior depends on project configuration files which may not be present, leading to inconsistent results across environments.

Suggested change
commands = mypy src/confluent_kafka
commands = mypy --strict src/confluent_kafka

Copilot uses AI. Check for mistakes.
Copy link
Member Author

Choose a reason for hiding this comment

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

We already have config in pyproject.toml


[pytest]
python_files = test_*
testpaths = tests
Expand Down