Skip to content

Commit

Permalink
drop support for Python 3.7
Browse files Browse the repository at this point in the history
Python 3.7 has reached end of life.
  • Loading branch information
dlech committed Sep 2, 2023
1 parent 3c1fac9 commit 33d1880
Show file tree
Hide file tree
Showing 14 changed files with 37 additions and 120 deletions.
2 changes: 1 addition & 1 deletion .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Before you submit a pull request, check that it meets these guidelines:
1. If the pull request adds functionality, the docs should be updated.
2. Modify the `CHANGELOG.rst`, describing your changes as is specified by the
guidelines in that document.
3. The pull request should work for Python 3.7+ on the following platforms:
3. The pull request should work for Python 3.8+ on the following platforms:
- Windows 10, version 16299 (Fall Creators Update) and greater
- Linux distributions with BlueZ >= 5.43
- OS X / macOS >= 10.11
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11']
python-version: ['3.8', '3.9', '3.10', '3.11']
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ Fixed
* Optimize BlueZ backend device watchers and condition callbacks to avoid linear searches
* Fixed WinRT backend sometimes hanging forever when a device goes out of range during connection. Fixes #1359.

Removed
-------
Dropped support for Python 3.7.

`0.20.2`_ (2023-04-19)
======================

Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ Before you submit a pull request, check that it meets these guidelines:
1. If the pull request adds functionality, the docs should be updated.
2. Modify the ``CHANGELOG.rst``, describing your changes as is specified by the
guidelines in that document.
3. The pull request should work for Python 3.7+ on the following platforms:
3. The pull request should work for Python 3.8+ on the following platforms:
- Windows 10, version 16299 (Fall Creators Update) and greater
- Linux distributions with BlueZ >= 5.43
- OS X / macOS >= 10.11
Expand Down
5 changes: 1 addition & 4 deletions bleak/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
overload,
)
from warnings import warn
from typing import Literal

if sys.version_info < (3, 12):
from typing_extensions import Buffer
Expand All @@ -41,10 +42,6 @@
else:
from asyncio import timeout as async_timeout

if sys.version_info[:2] < (3, 8):
from typing_extensions import Literal
else:
from typing import Literal

from .backends.characteristic import BleakGATTCharacteristic
from .backends.client import BaseBleakClient, get_platform_client_backend_type
Expand Down
8 changes: 1 addition & 7 deletions bleak/backends/bluezdbus/defs.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
# -*- coding: utf-8 -*-

import sys
from typing import Dict, List, Tuple

if sys.version_info[:2] < (3, 8):
from typing_extensions import Literal, TypedDict
else:
from typing import Literal, TypedDict
from typing import Dict, List, Literal, Tuple, TypedDict

# DBus Interfaces
OBJECT_MANAGER_INTERFACE = "org.freedesktop.DBus.ObjectManager"
Expand Down
8 changes: 1 addition & 7 deletions bleak/backends/bluezdbus/scanner.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
import logging
import sys
from typing import Callable, Coroutine, Dict, List, Optional
from typing import Callable, Coroutine, Dict, List, Literal, Optional, TypedDict
from warnings import warn

from dbus_fast import Variant

if sys.version_info[:2] < (3, 8):
from typing_extensions import Literal, TypedDict
else:
from typing import Literal, TypedDict

from ...exc import BleakError
from ..scanner import AdvertisementData, AdvertisementDataCallback, BaseBleakScanner
from .advertisement_monitor import OrPatternLike
Expand Down
8 changes: 1 addition & 7 deletions bleak/backends/corebluetooth/scanner.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
import logging
import sys
from typing import Any, Dict, List, Optional

if sys.version_info[:2] < (3, 8):
from typing_extensions import Literal, TypedDict
else:
from typing import Literal, TypedDict
from typing import Any, Dict, List, Literal, Optional, TypedDict

import objc
from CoreBluetooth import CBPeripheral
Expand Down
7 changes: 1 addition & 6 deletions bleak/backends/p4android/scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,13 @@
import logging
import sys
import warnings
from typing import List, Optional
from typing import List, Literal, Optional

if sys.version_info < (3, 11):
from async_timeout import timeout as async_timeout
else:
from asyncio import timeout as async_timeout

if sys.version_info[:2] < (3, 8):
from typing_extensions import Literal
else:
from typing import Literal

from android.broadcast import BroadcastReceiver
from android.permissions import Permission, request_permissions
from jnius import cast, java_method
Expand Down
29 changes: 18 additions & 11 deletions bleak/backends/winrt/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,19 @@
import uuid
import warnings
from ctypes import WinError
from typing import Any, Dict, List, Optional, Sequence, Set, Union, cast
from typing import (
Any,
Dict,
List,
Literal,
Optional,
Protocol,
Sequence,
Set,
TypedDict,
Union,
cast,
)

if sys.version_info < (3, 12):
from typing_extensions import Buffer
Expand All @@ -23,11 +35,6 @@
else:
from asyncio import timeout as async_timeout

if sys.version_info[:2] < (3, 8):
from typing_extensions import Literal, TypedDict
else:
from typing import Literal, TypedDict

from bleak_winrt.windows.devices.bluetooth import (
BluetoothAddressType,
BluetoothCacheMode,
Expand Down Expand Up @@ -73,10 +80,10 @@

logger = logging.getLogger(__name__)

# TODO: we can use this when minimum Python is 3.8
# class _Result(typing.Protocol):
# status: GattCommunicationStatus
# protocol_error: typing.Optional[int]

class _Result(Protocol):
status: GattCommunicationStatus
protocol_error: int


def _address_to_int(address: str) -> int:
Expand All @@ -95,7 +102,7 @@ def _address_to_int(address: str) -> int:
return int(address, base=16)


def _ensure_success(result: Any, attr: Optional[str], fail_msg: str) -> Any:
def _ensure_success(result: _Result, attr: Optional[str], fail_msg: str) -> Any:
"""
Ensures that *status* is ``GattCommunicationStatus.SUCCESS``, otherwise
raises ``BleakError``.
Expand Down
8 changes: 1 addition & 7 deletions bleak/backends/winrt/scanner.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import asyncio
import logging
import sys
from typing import Dict, List, NamedTuple, Optional
from typing import Dict, List, Literal, NamedTuple, Optional
from uuid import UUID

from bleak_winrt.windows.devices.bluetooth.advertisement import (
Expand All @@ -12,11 +11,6 @@
BluetoothLEScanningMode,
)

if sys.version_info[:2] < (3, 8):
from typing_extensions import Literal
else:
from typing import Literal

from ...assigned_numbers import AdvertisementDataType
from ...uuids import normalize_uuid_str
from ..scanner import AdvertisementData, AdvertisementDataCallback, BaseBleakScanner
Expand Down
59 changes: 2 additions & 57 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ classifiers = [
"Issues" = "https://github.com/hbldh/bleak/issues"

[tool.poetry.dependencies]
python = "^3.7"
python = "^3.8"
async-timeout = { version = ">= 3.0.0, < 5", python = "<3.11" }
typing-extensions = { version = ">=4.7.0", python = "<3.12" }
pyobjc-core = { version = "^9.0.1", markers = "platform_system=='Darwin'" }
Expand All @@ -32,15 +32,14 @@ bleak-winrt = { version = "^1.2.0", markers = "platform_system=='Windows'" }
dbus-fast = { version = "^1.83.0", markers = "platform_system == 'Linux'" }

[tool.poetry.group.docs.dependencies]
Sphinx = { version = "^5.1.1", python = ">=3.8" }
Sphinx = "^5.1.1"
sphinx-rtd-theme = "^1.0.0"

[tool.poetry.group.lint.dependencies]
black = "^22.1.0"
flake8 = { version = "^5.0.0", python = ">=3.8" }
flake8 = "^5.0.0"

[tool.poetry.group.test.dependencies]
asynctest = { version = "^0.13.0", python = "<3.8" }
pytest = "^7.0.0"
pytest-asyncio = "^0.19.0"
pytest-cov = "^3.0.0 "
Expand Down
8 changes: 1 addition & 7 deletions tests/bleak/backends/bluezdbus/test_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,10 @@

"""Tests for `bleak.backends.bluezdbus.version` package."""

import sys
from unittest.mock import Mock, patch
from unittest.mock import AsyncMock, Mock, patch

import pytest

if sys.version_info[:2] < (3, 8):
from asynctest.mock import CoroutineMock as AsyncMock
else:
from unittest.mock import AsyncMock

from bleak.backends.bluezdbus.version import BlueZFeatures


Expand Down

0 comments on commit 33d1880

Please sign in to comment.