Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
b735d60
mise venv for local development
richdawe-cio Jun 17, 2026
aa04d43
Test with more recent Python 3.x versions
richdawe-cio Jun 17, 2026
7edc159
Sync setup and test matrix Python versions
richdawe-cio Jun 17, 2026
01bff49
Update GHA; quote Python versions in test matrix
richdawe-cio Jun 17, 2026
e866deb
Python 3.6 is not supported by newer setup-python action
richdawe-cio Jun 17, 2026
e068f47
Downgrade setup-python, re-enable Python 3.6, and run whole test matr…
richdawe-cio Jun 17, 2026
880bd73
Split linting out from tests
richdawe-cio Jun 17, 2026
d7873fe
Remove Python 3.6, 3.7 from test matrix
richdawe-cio Jun 17, 2026
c747ab1
Bump setup-python in lint too
richdawe-cio Jun 17, 2026
c65edf8
Typo
richdawe-cio Jun 17, 2026
5a8da0c
Another typo
richdawe-cio Jun 17, 2026
c6b8a3f
Remove support for Python 3.6, 3.7
richdawe-cio Jun 22, 2026
1688eba
Latest doc URLs
richdawe-cio Jun 22, 2026
1fc2506
Bump version to 0.1.0
richdawe-cio Jun 22, 2026
9f4d991
Synchronise setup.py and requirements.txt
richdawe-cio Jun 22, 2026
22b9a98
Relax pylint
richdawe-cio Jun 22, 2026
c761e31
Bump version to 1.0.0; drop support for Python 3.6, 3.7 because of re…
richdawe-cio Jun 25, 2026
5b5a65b
Bump version to 1.0.0
richdawe-cio Jun 25, 2026
d5ded78
Review feedback
richdawe-cio Jun 25, 2026
7673d4e
Add lint-ci which fails only on linting errors
richdawe-cio Jun 25, 2026
de0ee97
Prefer using pip from venv to uv
richdawe-cio Jun 25, 2026
ddc5d6a
Fix pylint errors: missing __init__.py, import ordering, exception ha…
richdawe-cio Jun 25, 2026
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: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.0.2
current_version = 1.0.0
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)
serialize =
{major}.{minor}.{patch}
19 changes: 19 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Lint

on: [push]

jobs:
lint:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v6

- uses: actions/setup-python@v6
with:
python-version: "3.10"
cache: 'pip'
cache-dependency-path: setup.py

- run: pip3 install -e '.[test]'
- run: make lint-ci
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v6

- uses: actions/setup-python@v4
- uses: actions/setup-python@v6
with:
python-version: '3.x'
cache: 'pip'
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ jobs:
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
python-version: [3.7, 3.8, 3.9]
python-version: [ "3.8", "3.9", "3.10", "3.11", "3.12", "3.13", "3.14" ]

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

seems like 3.8 & 3.9 are also eol https://endoflife.date/python should we remove those as well?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I think I would keep these for now, since they are still available in GitHub runners.


steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v6

- uses: actions/setup-python@v4
- uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ build
.idea/
.python-version
venv
.venv
20 changes: 20 additions & 0 deletions .mise.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[env]
MISE_FETCH_REMOTE_VERSIONS_TIMEOUT = "30s"

_.python.venv = {
path = ".venv",
create = true,
}

[settings]
python.uv_venv_auto = false
python.venv_stdlib = true

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Prefer using venv over uv, and ensure that pip is installed in the venv.


[tools]
python = "3.11"

[tasks.test]
run = 'make install test'

[tasks.lint]
run = 'make install lint'
16 changes: 13 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,18 @@ install:
pip install --edit .[test]

test:
pylint --rcfile=.pylintrc --reports=y --exit-zero customerio/analytics
flake8 --max-complexity=10 --statistics customerio/analytics || true
python -m unittest customerio/analytics/test/*.py -v

.PHONY: install test
lint:
pylint --rcfile=.pylintrc --reports=y --exit-zero customerio/analytics
flake8 --max-complexity=10 --statistics --exit-zero customerio/analytics

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Invalid flake8 exit-zero flag

Medium Severity

The local lint target adds --exit-zero to the flake8 command. Flake8 3.7.x does not define that option (unlike pylint), so flake8 typically exits with an unrecognized-argument error and make lint / mise run lint fails before reporting style issues.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 7673d4e. Configure here.

@richdawe-cio richdawe-cio Jun 25, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Back in reality, this does not happen, and the command completes successfully with flake 3.7.9.


lint-ci:
pylint --rcfile=.pylintrc --exit-zero --fail-on=E customerio/analytics

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pylint CI never fails

Medium Severity

The new lint-ci target passes both --exit-zero and --fail-on=E to pylint. --exit-zero forces a zero exit status even when errors are reported, so the Lint workflow can pass while pylint reports E-level issues, undermining the split lint CI gate.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 7673d4e. Configure here.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

--fail-on=E seems to take precedence over --exit-zero, as seen in this failed lint run: https://github.com/customerio/cdp-analytics-python/actions/runs/28161429326/job/83402638737

flake8 --max-complexity=10 --max-line-length=100 --statistics customerio/analytics

clean:
rm -rf .venv
mise deps

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Clean target wrong mise command

Medium Severity

The new clean target removes .venv then runs mise deps, but this project’s .mise.toml only configures a Python venv and tasks—no mise deps providers. That command does not recreate the venv or reinstall pip install -e '.[test]', so make clean leaves local dev without the environment the PR documents.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit c761e31. Configure here.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

mise deps does actually recreate the venv. That's why I included it in this make target.


.PHONY: install test lint lint-ci clean
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Customer.io Data Pipelines analytics client for Python.
# Customer.io Data Pipelines analytics client for Python.

## Installation

Expand Down Expand Up @@ -40,6 +40,6 @@ analytics.track(user_id=4, event='order_complete')

The links below contain more detailed documentation on how to use this library:

* [Documentation](https://customer.io/docs/cdp/sources/connections/servers/python/)
* [Specs](https://customer.io/docs/cdp/sources/source-spec/source-events/)
* [Documentation](https://docs.customer.io/integrations/data-in/connections/servers/python/)
* [Specs](https://docs.customer.io/integrations/data-in/source-spec/incoming-data/)
* [PyPi](https://pypi.org/project/customerio-cdp-analytics/)
Empty file added customerio/__init__.py
Empty file.
17 changes: 9 additions & 8 deletions customerio/analytics/client.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
from datetime import datetime
from uuid import uuid4
import logging
import numbers
import atexit
import json
import logging
import numbers
import queue
from datetime import datetime
from uuid import uuid4

from dateutil.tz import tzutc

from customerio.analytics.utils import guess_timezone, clean
from customerio.analytics.consumer import Consumer, MAX_MSG_SIZE
from customerio.analytics.request import post, DatetimeSerializer
from customerio.analytics.utils import guess_timezone, clean
from customerio.analytics.version import VERSION

import queue

ID_TYPES = (numbers.Number, str)


Expand Down Expand Up @@ -269,7 +268,9 @@ def _enqueue(self, msg):
# Check message size.
msg_size = len(json.dumps(msg, cls=DatetimeSerializer).encode())
if msg_size > MAX_MSG_SIZE:
raise RuntimeError('Message exceeds %skb limit. (%s)', str(int(MAX_MSG_SIZE / 1024)), str(msg))
raise RuntimeError(
'Message exceeds %dkb limit. (%s)' % (MAX_MSG_SIZE // 1024, msg)
)

# if send is False, return msg as if it was successfully queued
if not self.send:
Expand Down
10 changes: 5 additions & 5 deletions customerio/analytics/consumer.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import json
import logging
from queue import Empty
from threading import Thread
import monotonic

import backoff
import json
import monotonic

from customerio.analytics.request import post, APIError, DatetimeSerializer

from queue import Empty

MAX_MSG_SIZE = 32 << 10

# Our servers only accept batches less than 500KB. Here limit is set slightly
Expand Down Expand Up @@ -73,7 +73,7 @@ def upload(self):
# mark items as acknowledged from queue
for _ in batch:
self.queue.task_done()
return success
return success

def next(self):
"""Return the next batch of items to upload."""
Expand Down
4 changes: 2 additions & 2 deletions customerio/analytics/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ def post(write_key, host=None, gzip=False, timeout=15, proxies=None, **kwargs):
payload = res.json()
log.debug('received response: %s', payload)
raise APIError(res.status_code, payload['code'], payload['message'])
except ValueError:
raise APIError(res.status_code, 'unknown', res.text)
except ValueError as exc:
raise APIError(res.status_code, 'unknown', res.text) from exc


class APIError(Exception):
Expand Down
5 changes: 3 additions & 2 deletions customerio/analytics/test/consumer.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import json
import time
import unittest

import mock
import time
import json

try:
from queue import Queue
Expand Down
2 changes: 1 addition & 1 deletion customerio/analytics/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
VERSION = '0.0.2'
VERSION = '1.0.0'
Comment thread
cursor[bot] marked this conversation as resolved.
7 changes: 7 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
backoff==2.2.1
flake8==3.7.9
monotonic==1.6
mock==2.0.0
pylint==3.3.3
python-dateutil==2.8.2
requests>=2.32.4
19 changes: 11 additions & 8 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@
'''

install_requires = [
"requests~=2.7",
"monotonic~=1.5",
"backoff~=2.1",
"python-dateutil~=2.2"
"requests>=2.32.4",
"monotonic~=1.6",
"backoff~=2.2",
"python-dateutil~=2.8"
]

tests_require = [
"mock==2.0.0",
"pylint==2.8.0",
"pylint>=3.2.0",
"flake8==3.7.9",
]

Expand All @@ -38,7 +38,7 @@
maintainer_email='cdp@customer.io',
test_suite='analytics.test.all',
packages=['customerio.analytics'],
python_requires='>=3.6.0',
python_requires='>=3.8.0',
license='MIT License',
install_requires=install_requires,
extras_require={
Expand All @@ -52,9 +52,12 @@
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
],
)