Skip to content

Commit 4cb403c

Browse files
nnethercottbrunoocasali
authored andcommitted
apply coderabbit suggestions
1 parent 75a0d9e commit 4cb403c

File tree

3 files changed

+8
-10
lines changed

3 files changed

+8
-10
lines changed

meilisearch/models/document.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,10 @@ class Document:
55
def __init__(self, doc: Dict[str, Any]) -> None:
66
self.__dict__.update(**doc)
77

8-
def __getattr__(self, attr: str) -> str:
9-
try:
8+
def __getattr__(self, attr: str) -> Any:
9+
if attr in self.__dict__:
1010
return self.__dict__[attr]
11-
except Exception as _:
12-
raise AttributeError(f"{self.__class__.__name__} object has no attribute {attr}")
11+
raise AttributeError(f"{self.__class__.__name__} object has no attribute {attr}")
1312

1413
def __iter__(self) -> Iterator:
1514
return iter(self.__dict__.items())

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@ disable=[
114114
"too-few-public-methods",
115115
"line-too-long",
116116
"too-many-positional-arguments",
117-
"raise-missing-from",
118117
]
119118
enable=[
120119
"use-symbolic-message-instead",

tests/models/test_document.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,22 @@
77

88

99
def test_doc_init():
10-
d = {"field1": "test 1", "fiels2": "test 2"}
10+
d = {"field1": "test 1", "field2": "test 2"}
1111
document = Document(d)
1212
assert dict(document) == d
1313

1414

1515
def test_getattr():
16-
document = Document({"field1": "test 1", "fiels2": "test 2"})
16+
document = Document({"field1": "test 1", "field2": "test 2"})
1717
assert document.__getattr__("field1") == "test 1"
1818

1919

2020
def test_getattr_not_found():
21-
document = Document({"field1": "test 1", "fiels2": "test 2"})
21+
document = Document({"field1": "test 1", "field2": "test 2"})
2222
with pytest.raises(AttributeError):
2323
document.__getattr__("bad")
2424

2525

2626
def test_iter():
27-
document = Document({"field1": "test 1", "fiels2": "test 2"})
28-
assert list(iter(document)) == [("field1", "test 1"), ("fiels2", "test 2")]
27+
document = Document({"field1": "test 1", "field2": "test 2"})
28+
assert list(iter(document)) == [("field1", "test 1"), ("field2", "test 2")]

0 commit comments

Comments
 (0)