Skip to content

Commit

Permalink
build: drop Python 3.7 and 3.8 support (#251)
Browse files Browse the repository at this point in the history
  • Loading branch information
terop authored Jul 27, 2024
1 parent e59fa3a commit b1f20af
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 31 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:

strategy:
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
python-version: ["3.9", "3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v4
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
### [Unreleased]
* ADD: Install Bleak automatically on all platforms
* CHANGE: Async Bleak adapter as default adapter on all platforms
* CHANGE: Support only Python 3.9 and above

## [2.3.1] - 2024-03-10
* ADD: Bluez as option to RUUVI_BLE_ADAPTER environment variable
Expand Down
20 changes: 18 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ RuuviTag Sensor Python Package
[![License](https://img.shields.io/pypi/l/ruuvitag-sensor.svg)](https://pypi.python.org/pypi/ruuvitag-sensor/)
[![PyPI version](https://img.shields.io/pypi/v/ruuvitag-sensor.svg)](https://pypi.python.org/pypi/ruuvitag_-sensor)
[![PyPI downloads](https://img.shields.io/pypi/dm/ruuvitag-sensor.svg)](https://pypistats.org/packages/ruuvitag-sensor)
[![Python versions](https://img.shields.io/badge/python-3.7+-blue.svg)](https://pypi.python.org/pypi/ruuvitag-sensor/)
[![Python versions](https://img.shields.io/badge/python-3.9+-blue.svg)](https://pypi.python.org/pypi/ruuvitag-sensor/)

`ruuvitag-sensor` is a Python package for communicating with [RuuviTag BLE Sensor](https://ruuvi.com/) and for decoding measurement data from broadcasted BLE data.

Expand All @@ -30,7 +30,8 @@ RuuviTag Sensor Python Package
* [Install guide](#BlueZ)
* __NOTE:__ The BlueZ-adapter implementation uses deprecated BlueZ tools that are no longer supported.
* Bleson-adapter supports sync-methods, but please be aware that it is not fully supported due to the alpha release status of the Bleson communication module. See [Bleson](#Bleson) for more information.
* Python 3.7+
* Python 3.9+
* For Python 3.7 and 3.8 support, check [installation instructions](#python-37-and-38) for an older version
* For Python 2.x or <3.7 support, check [installation instructions](#python-2x-and-36-and-below) for an older version

__NOTE:__ Version 2.0 contains method renames. When using a version prior to 2.0, check the documentation and examples from [PyPI](https://pypi.org/project/ruuvitag-sensor/) or in GitHub, switch to the correct release tag from _switch branches/tags_.
Expand Down Expand Up @@ -505,6 +506,21 @@ __NOTE:__ On macOS, only Data Format 5 works, as macOS doesn't advertise MAC add
__NOTE:__ On Windows, Bleson requires _Python 3.6_. Unfortunately on Windows, Bleson doesn't send any payload for the advertised package, so it is still unusable.


## Python 3.7 and 3.8

Last version of `ruuvitag-sensor` with Python 3.7 and 3.8 support is [2.3.1](https://pypi.org/project/ruuvitag-sensor/2.3.1/).

[Branch](https://github.com/ttu/ruuvitag-sensor/tree/release/2.3.1) / [Tag / commit](https://github.com/ttu/ruuvitag-sensor/commit/b16c9580d75eafe5508d0551642eb3b022ae1325)

```sh
$ git checkout release/2.3.1
```

Install from PyPI
```sh
$ python -m pip install ruuvitag-sensor==2.3.1
```

## Python 2.x and 3.6 and below

Last version of `ruuvitag-sensor` with Python 2.x and <3.7 support is [1.2.1](https://pypi.org/project/ruuvitag-sensor/1.2.1/).
Expand Down
10 changes: 3 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,9 @@ authors = [
description = "Find RuuviTag sensors and get decoded data from selected sensors"
readme = "README.md"
license = { file="LICENSE" }
requires-python = ">=3.7"
requires-python = ">=3.9"
classifiers = [
"Programming Language :: Python",
"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",
Expand All @@ -31,8 +29,6 @@ keywords = [ "RuuviTag BLE" ]
dependencies = [
"reactivex",
"ptyprocess;platform_system=='Linux'",
"mypy-extensions;python_version<'3.8'",
"importlib-metadata<4.3,>=1.1.0;python_version<'3.8'",
"bleak",
]

Expand All @@ -44,7 +40,7 @@ dev = [
"pylint",
"mypy",
"isort",
"black==23.3.0" # Lock black to the latest version that supports Python 3.7
"black"
]

[project.urls]
Expand Down Expand Up @@ -79,7 +75,7 @@ disable = [
]

[tool.mypy]
python_version = 3.8
python_version = 3.9
ignore_missing_imports = true

[tool.isort]
Expand Down
9 changes: 2 additions & 7 deletions ruuvitag_sensor/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
try:
import importlib.metadata # >=3.8
import importlib.metadata

__version__ = importlib.metadata.version(__package__ or __name__) # pylint: disable=no-member
except ImportError:
import importlib_metadata # <=3.7

__version__ = importlib_metadata.version(__package__ or __name__)
__version__ = importlib.metadata.version(__package__ or __name__) # pylint: disable=no-member
4 changes: 1 addition & 3 deletions ruuvitag_sensor/adapters/bleak_ble.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@ def _get_scanner(detection_callback: AdvertisementDataCallback, bt_device: str =
return BleakScanner(detection_callback=detection_callback, scanning_mode=scanning_mode) # type: ignore[arg-type]


# TODO: Python 3.7 - TypeError: 'type' object is not subscriptable
# queue = asyncio.Queue[Tuple[str, str]]()
queue = asyncio.Queue() # type: ignore
queue = asyncio.Queue[Tuple[str, str]]()

log = logging.getLogger(__name__)

Expand Down
4 changes: 1 addition & 3 deletions ruuvitag_sensor/ruuvi.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,9 +320,7 @@ def _parse_data(
mac_to_send = (
mac
if mac
else parse_mac(data_format, decoded["mac"])
if "mac" in decoded and decoded["mac"] is not None
else ""
else parse_mac(data_format, decoded["mac"]) if "mac" in decoded and decoded["mac"] is not None else ""
)

# Check whitelist using MAC from decoded data if advertised MAC is not available
Expand Down
7 changes: 1 addition & 6 deletions ruuvitag_sensor/ruuvi_types.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
from typing import Optional, Tuple, Union

try:
from typing import TypedDict # >=3.8
except ImportError:
from mypy_extensions import TypedDict # <=3.7
from typing import Optional, Tuple, TypedDict, Union


class SensorDataBase(TypedDict):
Expand Down
2 changes: 0 additions & 2 deletions tests/test_ruuvitag_sensor_async.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import asyncio
import sys
from typing import Tuple
from unittest.mock import patch

Expand All @@ -12,7 +11,6 @@
# pylint: disable=unused-argument


@pytest.mark.skipif(sys.version_info < (3, 8), reason="patch doesn't work correctly on 3.7")
@pytest.mark.asyncio
class TestRuuviTagSensorAsync:
async def _get_first_data(self, mac, bt_device):
Expand Down

0 comments on commit b1f20af

Please sign in to comment.