Skip to content

Commit

Permalink
feat: python 3.12 support
Browse files Browse the repository at this point in the history
  • Loading branch information
mahnunchik committed Sep 23, 2024
1 parent 4be3454 commit 0462d20
Show file tree
Hide file tree
Showing 13 changed files with 24 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
runs-on: ubuntu-22.04
strategy:
matrix:
python-version: ['3.8', '3.10']
python-version: ['3.8', '3.10', '3.12']

steps:
- uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion docs_src/generate_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from typing import Any, Dict, Iterator, List, Optional, Set, Tuple

import semver
import yaml
import yaml # type: ignore
from ast_to_xml import module_source
from git import Repo
from jinja2 import Template
Expand Down
2 changes: 1 addition & 1 deletion mqtt_io/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from hashlib import sha256
from typing import Any, Optional

import yaml
import yaml # type: ignore

from confp import render # type: ignore

Expand Down
2 changes: 1 addition & 1 deletion mqtt_io/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from typing import TYPE_CHECKING, Any, Dict, List, cast

import cerberus # type: ignore
import yaml
import yaml # type: ignore

from ..exceptions import ConfigValidationFailed
from ..types import ConfigType
Expand Down
5 changes: 3 additions & 2 deletions mqtt_io/modules/gpio/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import logging
from concurrent.futures import ThreadPoolExecutor
from enum import Enum, Flag, IntFlag, auto
from typing import Any, Callable, Dict, Iterable, List, Optional
from typing import Any, Callable, Dict, Iterable, List, Optional, cast

from ...types import ConfigType, PinType

Expand Down Expand Up @@ -213,7 +213,7 @@ def remote_interrupt_for(self, pin: PinType) -> List[str]:
"""
Return the list of pin names that this pin is a remote interrupt for.
"""
return self.pin_configs[pin].get("interrupt_for", [])
return cast(List[str], self.pin_configs[pin].get("interrupt_for", []))

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

async def get_interrupt_values_remote(
self, pins: List[PinType]
Expand Down
9 changes: 5 additions & 4 deletions mqtt_io/modules/gpio/mock.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def setup_interrupt_callback(
self.interrupt_callbacks[pin] = callback

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

def setup_pin(
self,
Expand All @@ -62,18 +62,19 @@ def setup_pin(
pin_config: ConfigType,
initial: Optional[str] = None,
) -> None:
return super().setup_pin(pin, direction, pullup, pin_config, initial=initial)
return super().setup_pin( # type: ignore[safe-super]
pin, direction, pullup, pin_config, initial=initial)

def setup_interrupt(
self, pin: PinType, edge: InterruptEdge, in_conf: ConfigType
) -> None:
return super().setup_interrupt(pin, edge, in_conf)

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

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

def get_int_pins(self) -> List[PinType]:
return super().get_int_pins()
Expand Down
2 changes: 1 addition & 1 deletion mqtt_io/modules/sensor/mock.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ def setup_sensor(self, sens_conf: ConfigType) -> None:
return super().setup_sensor(sens_conf)

def get_value(self, sens_conf: ConfigType) -> SensorValueType:
return super().get_value(sens_conf)
return super().get_value(sens_conf) # type: ignore[safe-super]
2 changes: 1 addition & 1 deletion mqtt_io/mqtt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class MQTTTLSOptions:
ca_certs: Optional[str] = None
certfile: Optional[str] = None
keyfile: Optional[str] = None
cert_reqs: int = ssl.CERT_REQUIRED
cert_reqs: ssl.VerifyMode = ssl.CERT_REQUIRED
tls_version: int = ssl.PROTOCOL_TLS
ciphers: Optional[str] = None

Expand Down
2 changes: 1 addition & 1 deletion mqtt_io/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -808,7 +808,7 @@ async def _mqtt_publish(self, msg: MQTTMessageSend, wait: bool = True) -> None:
)
else:
_LOG.debug(
"Publishing MQTT message on topic %r: %r", msg.topic, payload
"Publishing MQTT message on topic %r: %r", msg.topic, msg.payload
)

await self.mqtt.publish(msg)
Expand Down
2 changes: 1 addition & 1 deletion mqtt_io/tests/features/steps/config_main.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from typing import Any
import yaml
import yaml # type: ignore
from behave import given, then, when # type: ignore
from mqtt_io.config import validate_and_normalise_main_config
from mqtt_io.exceptions import ConfigValidationFailed
Expand Down
6 changes: 3 additions & 3 deletions mqtt_io/tests/features/steps/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
import concurrent.futures
from typing import Any, Dict, Type

import yaml
import yaml # type: ignore
from behave import given, then, when # type: ignore
from behave.api.async_step import async_run_until_complete # type: ignore
from mqtt_io import events
from mqtt_io.server import MqttIo

try:
from unittest.mock import AsyncMock # type: ignore[attr-defined]
from unittest.mock import AsyncMock # type: ignore
except ImportError:
from mock import AsyncMock # type: ignore[attr-defined]
from mock import AsyncMock # type: ignore

# pylint: disable=function-redefined,protected-access

Expand Down
6 changes: 3 additions & 3 deletions mqtt_io/tests/features/steps/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@
from typing import Any, Union
from unittest.mock import Mock

import yaml
import yaml # type: ignore
from behave import given, then, when # type: ignore
from behave.api.async_step import async_run_until_complete # type: ignore
from mqtt_io.exceptions import ConfigValidationFailed
from mqtt_io.mqtt import MQTTMessage, MQTTMessageSend
from mqtt_io.server import MqttIo

try:
from unittest.mock import AsyncMock # type: ignore[attr-defined]
from unittest.mock import AsyncMock # type: ignore
except ImportError:
from mock import AsyncMock # type: ignore[attr-defined]
from mock import AsyncMock # type: ignore

# pylint: disable=function-redefined

Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ docutils = "0.18.1"
mock = { version = "^4.0.3", python = ">=3.6,<3.8" }
pytest = "^6.2.2"
tox = "^3.22.0"
pylint = "^2.6.2"
mypy = "^0.812"
pylint = "^3.2.7"
mypy = "^1.11.2"
behave = "^1.2.6"
coverage = "^5.4"
md-toc = "^8.0.0"
Expand Down

0 comments on commit 0462d20

Please sign in to comment.