Skip to content

Commit

Permalink
lib.utils: Removed logging info and changed parameter typing to be co…
Browse files Browse the repository at this point in the history
…mpatible with Python 3.9 and under
  • Loading branch information
msinn committed Apr 26, 2024
1 parent de483dc commit cbecb05
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
4 changes: 2 additions & 2 deletions dev/sample_plugin/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
# https://www.smarthomeNG.de
# https://knx-user-forum.de/forum/supportforen/smarthome-py
#
# Sample plugin for new plugins to run with SmartHomeNG version 1.8 and
# upwards.
# Sample plugin for new plugins to run with SmartHomeNG version 1.10
# and up.
#
# SmartHomeNG is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Expand Down
9 changes: 6 additions & 3 deletions lib/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,8 @@ def is_timeframe(string: str) -> bool:
return False

@staticmethod
def to_timeframe(value: str | int) -> int:
# def to_timeframe(value: str | int) -> int: # works for Python 3.10 and above
def to_timeframe(value: str) -> int: # works for Python 3.9 and under
"""
Converts a timeframe value to milliseconds. See is_timeframe() method.
The special value 'now' is supported for the current time.
Expand Down Expand Up @@ -359,8 +360,10 @@ def is_float(string: str) -> bool:
return False

@staticmethod
def to_bool(value: str|int|float, default: bool='exception') -> bool:
"""
# def to_bool(value: str|int|float, default: bool='exception') -> bool: # works for Python 3.10 and above
def to_bool(value: str, default: bool = 'exception') -> bool: # works for Python 3.9 and under

"""
Converts a value to boolean.
Raises exception if value is a string and can't be converted and if no default value is given
Expand Down

0 comments on commit cbecb05

Please sign in to comment.