Skip to content

Commit

Permalink
Drop support for python 3.8 (#2112)
Browse files Browse the repository at this point in the history
  • Loading branch information
janiversen authored Mar 21, 2024
1 parent 79287f0 commit 58a1c37
Show file tree
Hide file tree
Showing 11 changed files with 26 additions and 24 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python: ['3.8', '3.9', '3.10', '3.11', '3.12']
python: ['3.9', '3.10', '3.11', '3.12']
include:
- python: '3.8'
- python: '3.9'
run_lint: true
- python: '3.12'
run_doc: true
Expand Down
6 changes: 3 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ Common features
* support all standard frames: socket, rtu, rtu-over-tcp, tcp and ascii
* does not have third party dependencies, apart from pyserial (optional)
* very lightweight project
* requires Python >= 3.8
* requires Python >= 3.9
* thorough test suite, that test all corners of the library
* automatically tested on Windows, Linux and MacOS combined with python 3.8 - 3.12
* automatically tested on Windows, Linux and MacOS combined with python 3.9 - 3.12
* strongly typed API (py.typed present)

The modbus protocol specification: Modbus_Application_Protocol_V1_1b3.pdf can be found on
Expand Down Expand Up @@ -276,7 +276,7 @@ There are 2 bigger projects ongoing:

Development instructions
------------------------
The current code base is compatible with python >= 3.8.
The current code base is compatible with python >= 3.9.

Here are some of the common commands to perform a range of activities::

Expand Down
2 changes: 0 additions & 2 deletions examples/contrib/explain.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
"""
How to explain pymodbus logs using https://rapidscada.net/modbus/ and requests.
Created on 7/19/2023 to support Python 3.8 to 3.11 on macOS, Ubuntu, or Windows.
"""
from __future__ import annotations

Expand Down
2 changes: 1 addition & 1 deletion examples/package_test_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
from __future__ import annotations

import asyncio
from typing import Callable
from collections.abc import Callable

import pymodbus.client as modbusClient
import pymodbus.server as modbusServer
Expand Down
7 changes: 4 additions & 3 deletions pymodbus/client/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@

import asyncio
import socket
from collections.abc import Awaitable, Callable
from dataclasses import dataclass
from typing import Any, Awaitable, Callable, Type, cast
from typing import Any, cast

from pymodbus.client.mixin import ModbusClientMixin
from pymodbus.exceptions import ConnectionException, ModbusIOException
Expand Down Expand Up @@ -90,7 +91,7 @@ def __init__(

# Common variables.
self.framer = FRAMER_NAME_TO_CLASS.get(
framer, cast(Type[ModbusFramer], framer)
framer, cast(type[ModbusFramer], framer)
)(ClientDecoder(), self)
self.transaction = ModbusTransactionManager(
self, retries=retries, retry_on_empty=retry_on_empty, **kwargs
Expand Down Expand Up @@ -344,7 +345,7 @@ def __init__(

# Common variables.
self.framer = FRAMER_NAME_TO_CLASS.get(
framer, cast(Type[ModbusFramer], framer)
framer, cast(type[ModbusFramer], framer)
)(ClientDecoder(), self)
self.transaction = ModbusTransactionManager(
self, retries=retries, retry_on_empty=retry_on_empty, **kwargs
Expand Down
3 changes: 2 additions & 1 deletion pymodbus/datastore/simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
import dataclasses
import random
import struct
from collections.abc import Callable
from datetime import datetime
from typing import Any, Callable
from typing import Any


WORD_SIZE = 16
Expand Down
7 changes: 4 additions & 3 deletions pymodbus/datastore/store.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@
from __future__ import annotations

from abc import ABC, abstractmethod
from typing import Any, Dict, Generic, Iterable, TypeVar
from collections.abc import Iterable
from typing import Any, Generic, TypeVar

from pymodbus.exceptions import ParameterException

Expand All @@ -57,7 +58,7 @@
# Datablock Storage
# ---------------------------------------------------------------------------#

V = TypeVar('V', list, Dict[int, Any])
V = TypeVar('V', list, dict[int, Any])
class BaseModbusDataBlock(ABC, Generic[V]):
"""Base class for a modbus datastore.
Expand Down Expand Up @@ -194,7 +195,7 @@ def setValues(self, address, values):
self.values[start : start + len(values)] = values


class ModbusSparseDataBlock(BaseModbusDataBlock[Dict[int, Any]]):
class ModbusSparseDataBlock(BaseModbusDataBlock[dict[int, Any]]):
"""A sparse modbus datastore.
E.g Usage.
Expand Down
8 changes: 4 additions & 4 deletions pymodbus/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"""

# pylint: disable=missing-type-doc
from typing import Callable, Dict
from collections.abc import Callable

from pymodbus.bit_read_message import (
ReadCoilsRequest,
Expand Down Expand Up @@ -163,15 +163,15 @@ class ServerDecoder:
]

@classmethod
def getFCdict(cls) -> Dict[int, Callable]:
def getFCdict(cls) -> dict[int, Callable]:
"""Build function code - class list."""
return {f.function_code: f for f in cls.__function_table} # type: ignore[attr-defined]

def __init__(self) -> None:
"""Initialize the client lookup tables."""
functions = {f.function_code for f in self.__function_table} # type: ignore[attr-defined]
self.lookup = self.getFCdict()
self.__sub_lookup: Dict[int, Dict[int, Callable]] = {f: {} for f in functions}
self.__sub_lookup: dict[int, dict[int, Callable]] = {f: {} for f in functions}
for f in self.__sub_function_table:
self.__sub_lookup[f.function_code][f.sub_function_code] = f # type: ignore[attr-defined]

Expand Down Expand Up @@ -300,7 +300,7 @@ def __init__(self) -> None:
"""Initialize the client lookup tables."""
functions = {f.function_code for f in self.function_table} # type: ignore[attr-defined]
self.lookup = {f.function_code: f for f in self.function_table} # type: ignore[attr-defined]
self.__sub_lookup: Dict[int, Dict[int, Callable]] = {f: {} for f in functions}
self.__sub_lookup: dict[int, dict[int, Callable]] = {f: {} for f in functions}
for f in self.__sub_function_table:
self.__sub_lookup[f.function_code][f.sub_function_code] = f # type: ignore[attr-defined]

Expand Down
3 changes: 2 additions & 1 deletion pymodbus/transport/transport.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,11 @@
import dataclasses
import ssl
from abc import abstractmethod
from collections.abc import Callable, Coroutine
from contextlib import suppress
from enum import Enum
from functools import partial
from typing import Any, Callable, Coroutine
from typing import Any

from pymodbus.logging import Log
from pymodbus.transport.serialtransport import create_serial_connection
Expand Down
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ classifiers = [
"Operating System :: MacOS :: MacOS X",
"Operating System :: OS Independent",
"Operating System :: Microsoft",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Topic :: System :: Networking",
"Topic :: Utilities",
]
requires-python = ">=3.8.0"
requires-python = ">=3.9.0"

[project.urls]
Homepage = "https://github.com/pymodbus-dev/pymodbus/"
Expand Down Expand Up @@ -129,7 +129,7 @@ load-plugins = [
"pylint.extensions.typing"
]
jobs = "0"
py-version = "3.8"
py-version = "3.9"

[tool.pylint.messages_control]
enable = "all"
Expand Down
2 changes: 1 addition & 1 deletion test/test_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from __future__ import annotations

import asyncio
from typing import Callable
from collections.abc import Callable

import pytest

Expand Down

0 comments on commit 58a1c37

Please sign in to comment.