Skip to content

Commit 4191b17

Browse files
authored
Python 3.8, 3.10, and 3.12 support (#404)
support python 3.8, 3.10 and 3.12 support
1 parent e4af383 commit 4191b17

File tree

18 files changed

+46
-44
lines changed

18 files changed

+46
-44
lines changed

.github/workflows/ci.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ on:
55
- release
66
jobs:
77
test:
8-
runs-on: ubuntu-20.04
8+
runs-on: ubuntu-22.04
99
strategy:
1010
matrix:
11-
python-version: [3.8]
11+
python-version: ['3.8', '3.10', '3.12']
1212

1313
steps:
14-
- uses: actions/checkout@v2
14+
- uses: actions/checkout@v4
1515
- name: Setup Python ${{ matrix.python-version }}
16-
uses: actions/setup-python@v2
16+
uses: actions/setup-python@v5
1717
with:
1818
python-version: ${{ matrix.python-version }}
1919
- name: Install dependencies
@@ -97,7 +97,7 @@ jobs:
9797
if: steps.branch-names.outputs.is_tag == 'false'
9898
run: |
9999
git checkout gh-pages
100-
git checkout ${{ steps.branch-names.outputs.current_branch }}
100+
git checkout ${{ steps.branch-names.outputs.current_branch }}
101101
- name: Setup Python 3.8
102102
uses: actions/setup-python@v2
103103
with:

docs_src/generate_docs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from typing import Any, Dict, Iterator, List, Optional, Set, Tuple
1414

1515
import semver
16-
import yaml
16+
import yaml # type: ignore
1717
from ast_to_xml import module_source
1818
from git import Repo
1919
from jinja2 import Template

mqtt_io/__main__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from hashlib import sha256
99
from typing import Any, Optional
1010

11-
import yaml
11+
import yaml # type: ignore
1212

1313
from confp import render # type: ignore
1414

mqtt_io/config/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from typing import TYPE_CHECKING, Any, Dict, List, cast
99

1010
import cerberus # type: ignore
11-
import yaml
11+
import yaml # type: ignore
1212

1313
from ..exceptions import ConfigValidationFailed
1414
from ..types import ConfigType

mqtt_io/modules/gpio/__init__.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import logging
1313
from concurrent.futures import ThreadPoolExecutor
1414
from enum import Enum, Flag, IntFlag, auto
15-
from typing import Any, Callable, Dict, Iterable, List, Optional
15+
from typing import Any, Callable, Dict, Iterable, List, Optional, cast
1616

1717
from ...types import ConfigType, PinType
1818

@@ -173,7 +173,7 @@ def setup_interrupt_internal(
173173
pin: PinType,
174174
edge: InterruptEdge,
175175
in_conf: ConfigType,
176-
callback: Optional[Callable[[List[Any], Dict[Any, Any]], None]] = None,
176+
callback: Optional[Callable[..., None]] = None,
177177
) -> None:
178178
"""
179179
Used internally to ensure that `self.interrupt_edges` is updated for this pin.
@@ -213,7 +213,7 @@ def remote_interrupt_for(self, pin: PinType) -> List[str]:
213213
"""
214214
Return the list of pin names that this pin is a remote interrupt for.
215215
"""
216-
return self.pin_configs[pin].get("interrupt_for", [])
216+
return cast(List[str], self.pin_configs[pin].get("interrupt_for", []))
217217

218218
def get_int_pins(self) -> List[PinType]:
219219
"""
@@ -274,6 +274,7 @@ def get_interrupt_value(self, pin: PinType, *args: Any, **kwargs: Any) -> bool:
274274
for the value, or looking it up in a register that captures the value at time of
275275
interrupt.
276276
"""
277+
return False
277278

278279
async def get_interrupt_values_remote(
279280
self, pins: List[PinType]

mqtt_io/modules/gpio/gpiozero.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"""
44
import logging
55
from functools import partial
6-
from typing import Optional, Any, Callable, List, Dict, TYPE_CHECKING, cast
6+
from typing import Optional, Any, Callable, Dict, TYPE_CHECKING, cast
77

88
from mqtt_io.modules.gpio import (
99
GenericGPIO,
@@ -89,7 +89,7 @@ def setup_interrupt_callback(
8989
pin: PinType,
9090
edge: InterruptEdge,
9191
in_conf: ConfigType,
92-
callback: Callable[[List[Any], Dict[Any, Any]], None],
92+
callback: Callable[..., None],
9393
) -> None:
9494
_LOG.debug(
9595
"Added interrupt to gpiozero Pi pin '%s' with callback '%s'", pin, callback

mqtt_io/modules/gpio/mock.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Mock GPIO module for using with the tests.
33
"""
44

5-
from typing import Any, Callable, Dict, Iterable, List, Optional
5+
from typing import Callable, Dict, Iterable, List, Optional
66
from unittest.mock import Mock
77

88
from ...types import ConfigType, PinType
@@ -39,20 +39,20 @@ def __init__(self, config: ConfigType):
3939

4040
super().__init__(config)
4141
self.interrupt_callbacks: Dict[
42-
PinType, Callable[[List[Any], Dict[Any, Any]], None]
42+
PinType, Callable[..., None]
4343
] = {}
4444

4545
def setup_interrupt_callback(
4646
self,
4747
pin: PinType,
4848
edge: InterruptEdge,
4949
in_conf: ConfigType,
50-
callback: Callable[[List[Any], Dict[Any, Any]], None],
50+
callback: Callable[..., None],
5151
) -> None:
5252
self.interrupt_callbacks[pin] = callback
5353

5454
def setup_module(self) -> None:
55-
return super().setup_module()
55+
return super().setup_module() # type: ignore[safe-super]
5656

5757
def setup_pin(
5858
self,
@@ -62,18 +62,19 @@ def setup_pin(
6262
pin_config: ConfigType,
6363
initial: Optional[str] = None,
6464
) -> None:
65-
return super().setup_pin(pin, direction, pullup, pin_config, initial=initial)
65+
return super().setup_pin( # type: ignore[safe-super]
66+
pin, direction, pullup, pin_config, initial=initial)
6667

6768
def setup_interrupt(
6869
self, pin: PinType, edge: InterruptEdge, in_conf: ConfigType
6970
) -> None:
7071
return super().setup_interrupt(pin, edge, in_conf)
7172

7273
def set_pin(self, pin: PinType, value: bool) -> None:
73-
return super().set_pin(pin, value)
74+
return super().set_pin(pin, value) # type: ignore[safe-super]
7475

7576
def get_pin(self, pin: PinType) -> bool:
76-
return super().get_pin(pin)
77+
return super().get_pin(pin) # type: ignore[safe-super]
7778

7879
def get_int_pins(self) -> List[PinType]:
7980
return super().get_int_pins()

mqtt_io/modules/gpio/raspberrypi.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"""
44

55
import logging
6-
from typing import Any, Callable, Dict, List, Optional
6+
from typing import Any, Callable, Optional
77

88
from ...types import ConfigType, PinType
99
from . import GenericGPIO, InterruptEdge, InterruptSupport, PinDirection, PinPUD
@@ -60,7 +60,7 @@ def setup_interrupt_callback(
6060
pin: PinType,
6161
edge: InterruptEdge,
6262
in_conf: ConfigType,
63-
callback: Callable[[List[Any], Dict[Any, Any]], None],
63+
callback: Callable[..., None],
6464
) -> None:
6565
gpio_edge = self.interrupt_edge_map[edge]
6666
_LOG.debug(

mqtt_io/modules/sensor/mock.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,4 @@ def setup_sensor(self, sens_conf: ConfigType) -> None:
3030
return super().setup_sensor(sens_conf)
3131

3232
def get_value(self, sens_conf: ConfigType) -> SensorValueType:
33-
return super().get_value(sens_conf)
33+
return super().get_value(sens_conf) # type: ignore[safe-super]

mqtt_io/mqtt/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class MQTTTLSOptions:
6161
ca_certs: Optional[str] = None
6262
certfile: Optional[str] = None
6363
keyfile: Optional[str] = None
64-
cert_reqs: int = ssl.CERT_REQUIRED
64+
cert_reqs: ssl.VerifyMode = ssl.CERT_REQUIRED
6565
tls_version: int = ssl.PROTOCOL_TLS
6666
ciphers: Optional[str] = None
6767

0 commit comments

Comments
 (0)