Skip to content

Commit 6d80f93

Browse files
committed
Update ruff
1 parent 7d87b06 commit 6d80f93

4 files changed

Lines changed: 58 additions & 83 deletions

File tree

poetry.lock

Lines changed: 22 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ packages = [
3030

3131
[tool.poetry.group.dev.dependencies]
3232
coverage = "^5.3"
33-
ruff = "^0.0.171"
33+
ruff = "^0.14.0"
3434
isort = "^5.10.1"
3535
black = "^24.3.0"
3636
nose2 = "^0.12.0"
@@ -40,9 +40,11 @@ line-length = 119
4040

4141
[tool.ruff]
4242
line-length = 120
43+
fix = true
44+
45+
[tool.ruff.lint]
4346
select = ["E", "F", "W"]
4447
ignore = ["E501", "F405"]
45-
fix = true
4648

4749
[tool.isort]
4850
multi_line_output = 3

temba_client/exceptions.py

Lines changed: 30 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,30 @@
1-
class TembaException(Exception):
2-
def __str__(self):
3-
return self.message
4-
5-
6-
class TembaConnectionError(TembaException):
7-
message = "Unable to connect to host"
8-
9-
10-
class TembaBadRequestError(TembaException):
11-
def __init__(self, errors):
12-
self.errors = errors
13-
14-
def __str__(self):
15-
msgs = []
16-
if isinstance(self.errors, dict):
17-
for field, field_errors in self.errors.items():
18-
if isinstance(field_errors, str): # e.g. {"detail": "message..."}
19-
msgs.append(field_errors)
20-
else:
21-
for error in field_errors: # e.g. {"field1": ["msg1...", "msg2..."]}
22-
msgs.append(error)
23-
elif isinstance(self.errors, list):
24-
msgs = self.errors
25-
26-
return msgs[0] if len(msgs) == 1 else ". ".join(msgs)
27-
28-
29-
class TembaTokenError(TembaException):
30-
message = "Authentication with provided token failed"
31-
32-
33-
class TembaNoSuchObjectError(TembaException):
34-
message = "No such object exists"
35-
36-
37-
class TembaRateExceededError(TembaException):
38-
message = (
39-
"You have exceeded the number of requests allowed per org in a given time window. "
40-
"Please wait %d seconds before making further requests"
41-
)
42-
43-
def __init__(self, retry_after):
44-
self.retry_after = retry_after
45-
46-
def __str__(self):
47-
return self.message % self.retry_after
48-
49-
50-
class TembaHttpError(TembaException):
51-
def __init__(self, caused_by):
52-
self.caused_by = caused_by
53-
54-
def __str__(self):
55-
return str(self.caused_by)
56-
57-
58-
class TembaSerializationException(TembaException):
59-
def __init__(self, message):
60-
self.message = message
1+
[
2+
{
3+
"code": "E902",
4+
"message": "No such file or directory (os error 2)",
5+
"fix": None,
6+
"location": {
7+
"row": 0,
8+
"column": 0
9+
},
10+
"end_location": {
11+
"row": 0,
12+
"column": 0
13+
},
14+
"filename": "/Users/norbert/nyaruka/rapidpro-python/-"
15+
},
16+
{
17+
"code": "E902",
18+
"message": "No such file or directory (os error 2)",
19+
"fix": None,
20+
"location": {
21+
"row": 0,
22+
"column": 0
23+
},
24+
"end_location": {
25+
"row": 0,
26+
"column": 0
27+
},
28+
"filename": "/Users/norbert/nyaruka/rapidpro-python/check"
29+
}
30+
]

temba_client/serialization.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,14 +100,14 @@ def deserialize(self, value):
100100

101101
class IntegerField(SimpleField):
102102
def deserialize(self, value):
103-
if value is not None and type(value) != int:
103+
if value is not None and not isinstance(value, int):
104104
raise TembaSerializationException("Value '%s' field is not an integer" % str(value))
105105
return value
106106

107107

108108
class ListField(SimpleField):
109109
def deserialize(self, value):
110-
if value is not None and type(value) != list:
110+
if value is not None and not isinstance(value, list):
111111
raise TembaSerializationException("Value '%s' field is not a list" % str(value))
112112
return value
113113

0 commit comments

Comments
 (0)