Skip to content

Commit 28d180d

Browse files
v2.0.5: support python 3.9
1 parent b95b3a3 commit 28d180d

File tree

5 files changed

+11
-8
lines changed

5 files changed

+11
-8
lines changed

farmbot/functions/api.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ def request_handling(self, response, make_request):
127127

128128
try:
129129
response.json()
130-
except requests.exceptions.JSONDecodeError:
130+
except (json.JSONDecodeError, requests.exceptions.RequestException):
131131
self.state.error += f" ({text})"
132132
else:
133133
self.state.error += f" ({json.dumps(response.json(), indent=2)})"

farmbot/functions/broker.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ def wrapper(self, *args, **kwargs):
241241
self.stop_listen()
242242
return wrapper
243243

244-
@stop_listen_upon_interrupt
244+
@stop_listen_upon_interrupt.__func__
245245
def listen(self,
246246
channel="#",
247247
duration=None,

farmbot/main.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
from .functions.resources import Resources
1616
from .functions.tools import ToolControls
1717

18-
VERSION = "2.0.4"
18+
VERSION = "2.0.5"
1919

2020

2121
class Farmbot():

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ authors = [
1212
keywords = ["farmbot"]
1313
description = "FarmBot Python package"
1414
readme = "README.md"
15-
requires-python = ">=3.8"
15+
requires-python = ">=3.9"
1616
classifiers = [
1717
"Programming Language :: Python :: 3",
1818
"License :: OSI Approved :: MIT License",

tests/tests_main.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
Farmbot class unit tests.
33
'''
44

5+
import sys
56
import json
67
import unittest
78
from unittest.mock import Mock, patch, call
@@ -39,6 +40,10 @@
3940
}
4041

4142

43+
JSONDecodeError = requests.exceptions.JSONDecodeError if sys.version_info >= (
44+
3, 10) else json.JSONDecodeError
45+
46+
4247
class TestFarmbot(unittest.TestCase):
4348
'''Farmbot tests'''
4449

@@ -223,8 +228,7 @@ def test_api_string_error_response_handling(self, mock_request):
223228
mock_response.status_code = 404
224229
mock_response.reason = 'reason'
225230
mock_response.text = 'error string'
226-
mock_response.json.side_effect = requests.exceptions.JSONDecodeError(
227-
'', '', 0)
231+
mock_response.json.side_effect = JSONDecodeError('', '', 0)
228232
mock_request.return_value = mock_response
229233
response = self.fb.api_get('device')
230234
mock_request.assert_called_once_with(
@@ -243,8 +247,7 @@ def test_api_string_error_response_handling_html(self, mock_request):
243247
mock_response.status_code = 404
244248
mock_response.reason = 'reason'
245249
mock_response.text = '<html><h1>error0</h1><h2>error1</h2></html>'
246-
mock_response.json.side_effect = requests.exceptions.JSONDecodeError(
247-
'', '', 0)
250+
mock_response.json.side_effect = JSONDecodeError('', '', 0)
248251
mock_request.return_value = mock_response
249252
response = self.fb.api_get('device')
250253
mock_request.assert_called_once_with(

0 commit comments

Comments
 (0)