Skip to content

Commit

Permalink
Migrate to pytest and drop support for Python 2 (#351)
Browse files Browse the repository at this point in the history
* Migrate to pytest

* Drop support for Python 2 and update all dependencies

---------

Co-authored-by: Christopher Peplin <[email protected]>
  • Loading branch information
Sigmanificient and peplin authored Aug 3, 2024
1 parent 70c6868 commit 7e564ce
Show file tree
Hide file tree
Showing 31 changed files with 1,888 additions and 1,708 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.7'
python-version: '3.12'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ jobs:
tests:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: [2.7, 3.9]
python-version: [3.9, 3.12]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ cover/
.coverage
output.xml
flake8.log
nosetests.xml
pylint.log
.idea/
dist/
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
Release History
================

V5.0.0
------

* Drop support for Python 2

V4.0.5
------

Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ uninstall:

clean:
@rm -rf *.egg* build dist *.py[oc] */*.py[co] cover doctest_pypi.cfg \
nosetests.xml pylint.log output.xml flake8.log tests.log \
pylint.log output.xml flake8.log tests.log \
test-result.xml htmlcov fab.log .coverage

publish:
Expand Down
5 changes: 1 addition & 4 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,7 @@ leaves something to be desired and only works in Linux.
Requirements
------------

- Python 2.7.5 or greater, or Python 3.5 or greater

- Python 2.7.3's ``struct`` library has a bug that will break PyGATT - 2.7.5
or greater is recommended.
- Python 3.9 or greater

- BlueZ 5.18 or greater (with gatttool) - required for the gatttool
backend only.
Expand Down
1 change: 1 addition & 0 deletions pygatt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ class NullHandler(logging.Handler):
def emit(self, record):
pass


# Initialize a null handler for logging to avoid printing spurious "No handlers
# could be found for logger" messages.
logging.getLogger(__name__).addHandler(NullHandler())
Expand Down
16 changes: 9 additions & 7 deletions pygatt/backends/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

DEFAULT_CONNECT_TIMEOUT_S = 5.0

BLEAddressType = Enum('BLEAddressType', 'public random')
BLEAddressType = Enum("BLEAddressType", "public random")


class BLEBackend(object):
Expand All @@ -21,8 +21,7 @@ def start(self):
raise NotImplementedError()

def stop(self):
"""Stop and free any resources required while the backend is running.
"""
"""Stop and free any resources required while the backend is running."""
raise NotImplementedError()

def supports_unbonded(self):
Expand Down Expand Up @@ -54,8 +53,7 @@ def filtered_scan(self, name_filter="", *args, **kwargs):
Returns a list of BLE devices found.
"""
devices = self.scan(*args, **kwargs)
return [device for device in devices
if name_filter in (device['name'] or '')]
return [device for device in devices if name_filter in (device["name"] or "")]

def clear_bond(self, address=None):
raise NotImplementedError()
Expand All @@ -67,6 +65,7 @@ class Characteristic(object):
Only valid for the lifespan of a BLE connection, since the handle values are
dynamic.
"""

def __init__(self, uuid, handle):
"""
Sets the characteritic uuid and handle.
Expand All @@ -86,5 +85,8 @@ def add_descriptor(self, uuid, handle):
self.descriptors[uuid] = handle

def __str__(self):
return "<%s uuid=%s handle=%d>" % (self.__class__.__name__,
self.uuid, self.handle)
return "<%s uuid=%s handle=%d>" % (
self.__class__.__name__,
self.uuid,
self.handle,
)
Loading

0 comments on commit 7e564ce

Please sign in to comment.