Skip to content
Closed
Show file tree
Hide file tree
Changes from 5 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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,5 @@ tmp-KafkaCluster
.venv
venv_test
venv_examples
.vscode/
.dmypy.json
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,10 @@ install:
script:
- flake8
# Build package
- pip install --global-option=build_ext --global-option="-Itmp-build/include/" --global-option="-Ltmp-build/lib" . .[avro] .[schema-registry] .[json] .[protobuf]
- pip install --global-option=build_ext --global-option="-Itmp-build/include/" --global-option="-Ltmp-build/lib" . .[avro] .[schema-registry] .[json] .[protobuf]
- ldd staging/libs/* || otool -L staging/libs/* || true
# Run type checks
- mypy src/confluent_kafka
# Run tests
- if [[ $TRAVIS_OS_NAME == "linux" ]]; then LD_LIBRARY_PATH=$LD_LIBRARY_PATH:staging/libs DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:staging/libs python -m pytest --timeout 600 --ignore=tmp-build || travis_terminate 1; fi
# Build docs
Expand Down
6 changes: 6 additions & 0 deletions mypy.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[mypy]
show_error_codes=true
disallow_untyped_defs=true
disallow_untyped_calls=true
warn_redundant_casts=true
strict_optional=true
10 changes: 9 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,20 @@
INSTALL_REQUIRES = [
'futures;python_version<"3.2"',
'enum34;python_version<"3.4"',
'six'
]

TEST_REQUIRES = [
'pytest==4.6.4;python_version<"3.0"',
'pytest;python_version>="3.0"',
'pytest-timeout',
'flake8'
'flake8',
# Cap the version to avoid issues with newer editions. Should be periodically updated!
'mypy<=0.991',
'types-protobuf',
'types-jsonschema',
'types-requests',
'types-six'
]

DOC_REQUIRES = ['sphinx', 'sphinx-rtd-theme']
Expand Down Expand Up @@ -81,6 +88,7 @@ def get_install_requirements(path):
author_email='[email protected]',
url='https://github.com/confluentinc/confluent-kafka-python',
ext_modules=[module],
package_data={"confluent_kafka": ["py.typed"]},
packages=find_packages('src'),
package_dir={'': 'src'},
data_files=[('', [os.path.join(work_dir, 'LICENSE.txt')])],
Expand Down
10 changes: 5 additions & 5 deletions src/confluent_kafka/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,19 +60,19 @@ class ThrottleEvent(object):
:ivar float throttle_time: The amount of time (in seconds) the broker throttled (delayed) the request
"""

def __init__(self, broker_name,
broker_id,
throttle_time):
def __init__(self, broker_name: str,
broker_id: int,
throttle_time: float):
self.broker_name = broker_name
self.broker_id = broker_id
self.throttle_time = throttle_time

def __str__(self):
def __str__(self) -> str:
return "{}/{} throttled for {} ms".format(self.broker_name, self.broker_id,
int(self.throttle_time * 1000))


def _resolve_plugins(plugins):
def _resolve_plugins(plugins: str) -> str:
""" Resolve embedded plugins from the wheel's library directory.

For internal module use only.
Expand Down
Loading