Skip to content

Commit b2bff02

Browse files
committed
refactor: fix some pytest ruff warning
1 parent b801291 commit b2bff02

File tree

10 files changed

+38
-40
lines changed

10 files changed

+38
-40
lines changed

pyproject.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,9 @@ select = [
270270
"ISC",
271271
"G",
272272
#"INP",
273-
"PIE"
273+
"PIE",
274+
# "T20",
275+
"PT"
274276
]
275277

276278

tests/robotcode/jsonrpc/test_jsonrpcprotocol.py

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def event_loop() -> Iterator[asyncio.AbstractEventLoop]:
4242
loop.close()
4343

4444

45-
@pytest.mark.asyncio
45+
@pytest.mark.asyncio()
4646
async def test_receive_a_request_message_should_work() -> None:
4747
protocol = DummyJsonRPCProtocol(None)
4848

@@ -57,7 +57,7 @@ async def test_receive_a_request_message_should_work() -> None:
5757
assert protocol.handled_messages == [message]
5858

5959

60-
@pytest.mark.asyncio
60+
@pytest.mark.asyncio()
6161
async def test_receive_a_request_message_should_work_with_string_id() -> None:
6262
protocol = DummyJsonRPCProtocol(None)
6363

@@ -72,7 +72,7 @@ async def test_receive_a_request_message_should_work_with_string_id() -> None:
7272
assert protocol.handled_messages == [message]
7373

7474

75-
@pytest.mark.asyncio
75+
@pytest.mark.asyncio()
7676
async def test_receive_a_batch_request_should_work() -> None:
7777
protocol = DummyJsonRPCProtocol(None)
7878

@@ -91,7 +91,7 @@ async def test_receive_a_batch_request_should_work() -> None:
9191
assert protocol.handled_messages == message
9292

9393

94-
@pytest.mark.asyncio
94+
@pytest.mark.asyncio()
9595
async def test_receive_invalid_jsonmessage_should_throw_send_an_error() -> None:
9696
protocol = DummyJsonRPCProtocol(None)
9797

@@ -100,13 +100,11 @@ async def test_receive_invalid_jsonmessage_should_throw_send_an_error() -> None:
100100
data = header + json_message
101101

102102
await protocol.data_received_async(data)
103-
assert (
104-
isinstance(protocol.sended_message, JsonRPCError)
105-
and protocol.sended_message.error.code == JsonRPCErrors.PARSE_ERROR
106-
)
103+
assert isinstance(protocol.sended_message, JsonRPCError)
104+
assert protocol.sended_message.error.code == JsonRPCErrors.PARSE_ERROR
107105

108106

109-
@pytest.mark.asyncio
107+
@pytest.mark.asyncio()
110108
async def test_receive_a_request_with_invalid_protocol_version_should_send_an_error() -> None:
111109
protocol = DummyJsonRPCProtocol(None)
112110

@@ -117,13 +115,11 @@ async def test_receive_a_request_with_invalid_protocol_version_should_send_an_er
117115
header = f"Content-Length: {len(json_message)}\r\n\r\n".encode("ascii")
118116
data = header + json_message
119117
await protocol.data_received_async(data)
120-
assert (
121-
isinstance(protocol.sended_message, JsonRPCError)
122-
and protocol.sended_message.error.code == JsonRPCErrors.PARSE_ERROR
123-
)
118+
assert isinstance(protocol.sended_message, JsonRPCError)
119+
assert protocol.sended_message.error.code == JsonRPCErrors.PARSE_ERROR
124120

125121

126-
@pytest.mark.asyncio
122+
@pytest.mark.asyncio()
127123
async def test_receive_an_error_should_work() -> None:
128124
protocol = DummyJsonRPCProtocol(None)
129125

@@ -136,7 +132,7 @@ async def test_receive_an_error_should_work() -> None:
136132
assert protocol.handled_messages == [message]
137133

138134

139-
@pytest.mark.asyncio
135+
@pytest.mark.asyncio()
140136
async def test_receive_response_should_work() -> None:
141137
protocol = DummyJsonRPCProtocol(None)
142138

@@ -153,7 +149,7 @@ async def test_receive_response_should_work() -> None:
153149
assert a == ["dummy", "data"]
154150

155151

156-
@pytest.mark.asyncio
152+
@pytest.mark.asyncio()
157153
async def test_receive_invalid_id_in_response_should_send_an_error() -> None:
158154
protocol = DummyJsonRPCProtocol(None)
159155

@@ -167,7 +163,7 @@ async def test_receive_invalid_id_in_response_should_send_an_error() -> None:
167163
assert isinstance(protocol.sended_message, JsonRPCError)
168164

169165

170-
@pytest.mark.asyncio
166+
@pytest.mark.asyncio()
171167
async def test_send_request_receive_response_should_work_without_param_type_work() -> None:
172168
protocol = DummyJsonRPCProtocol(None)
173169

@@ -187,7 +183,7 @@ async def test_send_request_receive_response_should_work_without_param_type_work
187183
assert a == {"title": "hi there"}
188184

189185

190-
@pytest.mark.asyncio
186+
@pytest.mark.asyncio()
191187
async def test_receive_response_should_work_with_dataclass() -> None:
192188
protocol = DummyJsonRPCProtocol(None)
193189

@@ -206,7 +202,7 @@ async def test_receive_response_should_work_with_dataclass() -> None:
206202
assert a == MessageActionItem(title="hi there")
207203

208204

209-
@pytest.mark.asyncio
205+
@pytest.mark.asyncio()
210206
async def test_receive_response_should_work_with_generic_list() -> None:
211207
protocol = DummyJsonRPCProtocol(None)
212208

@@ -225,7 +221,7 @@ async def test_receive_response_should_work_with_generic_list() -> None:
225221
assert a == [MessageActionItem(title="hi there")]
226222

227223

228-
@pytest.mark.asyncio
224+
@pytest.mark.asyncio()
229225
async def test_receive_response_with_generic_dict_should_return_unchanged() -> None:
230226
protocol = DummyJsonRPCProtocol(None)
231227

tests/robotcode/language_server/common/test_text_document.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from robotcode.utils.async_tools import check_canceled
99

1010

11-
@pytest.mark.asyncio
11+
@pytest.mark.asyncio()
1212
async def test_apply_full_change_should_work() -> None:
1313
text = """first"""
1414
new_text = """changed"""
@@ -20,7 +20,7 @@ async def test_apply_full_change_should_work() -> None:
2020
assert document.text() == new_text
2121

2222

23-
@pytest.mark.asyncio
23+
@pytest.mark.asyncio()
2424
async def test_apply_apply_incremental_change_at_begining_should_work() -> None:
2525
text = """first"""
2626
new_text = """changed"""
@@ -34,7 +34,7 @@ async def test_apply_apply_incremental_change_at_begining_should_work() -> None:
3434
assert document.text() == new_text + text
3535

3636

37-
@pytest.mark.asyncio
37+
@pytest.mark.asyncio()
3838
async def test_apply_apply_incremental_change_at_end_should_work() -> None:
3939
text = """first"""
4040
new_text = """changed"""
@@ -49,7 +49,7 @@ async def test_apply_apply_incremental_change_at_end_should_work() -> None:
4949
assert document.text() == text + new_text
5050

5151

52-
@pytest.mark.asyncio
52+
@pytest.mark.asyncio()
5353
async def test_save_and_revert_should_work() -> None:
5454
text = """first"""
5555
new_text = """changed"""
@@ -82,7 +82,7 @@ async def test_save_and_revert_should_work() -> None:
8282
assert document.version == 2
8383

8484

85-
@pytest.mark.asyncio
85+
@pytest.mark.asyncio()
8686
async def test_apply_apply_incremental_change_in_the_middle_should_work() -> None:
8787
text = """\
8888
first line
@@ -104,7 +104,7 @@ async def test_apply_apply_incremental_change_in_the_middle_should_work() -> Non
104104
assert document.text() == expected
105105

106106

107-
@pytest.mark.asyncio
107+
@pytest.mark.asyncio()
108108
async def test_apply_apply_incremental_change_with_start_line_eq_len_lines_should_work() -> None:
109109
text = """\
110110
first line
@@ -122,7 +122,7 @@ async def test_apply_apply_incremental_change_with_start_line_eq_len_lines_shoul
122122
assert document.text() == text + new_text
123123

124124

125-
@pytest.mark.asyncio
125+
@pytest.mark.asyncio()
126126
async def test_apply_apply_incremental_change_with_wrong_range_should_raise_invalidrangerrror() -> None:
127127
text = """first"""
128128
new_text = """changed"""
@@ -136,7 +136,7 @@ async def test_apply_apply_incremental_change_with_wrong_range_should_raise_inva
136136
)
137137

138138

139-
@pytest.mark.asyncio
139+
@pytest.mark.asyncio()
140140
async def test_apply_none_change_should_work() -> None:
141141
text = """first"""
142142

@@ -148,7 +148,7 @@ async def test_apply_none_change_should_work() -> None:
148148
assert document.text() == text
149149

150150

151-
@pytest.mark.asyncio
151+
@pytest.mark.asyncio()
152152
async def test_lines_should_give_the_lines_of_the_document() -> None:
153153
text = """\
154154
first
@@ -164,7 +164,7 @@ async def test_lines_should_give_the_lines_of_the_document() -> None:
164164
assert document.get_lines() == text.splitlines(True)
165165

166166

167-
@pytest.mark.asyncio
167+
@pytest.mark.asyncio()
168168
async def test_document_get_set_clear_data_should_work() -> None:
169169
text = """\
170170
first
@@ -191,7 +191,7 @@ class WeakReferencable:
191191
assert document.get_data(key, None) is None
192192

193193

194-
@pytest.mark.asyncio
194+
@pytest.mark.asyncio()
195195
async def test_document_get_set_cache_with_function_should_work() -> None:
196196
text = """\
197197
first
@@ -222,7 +222,7 @@ async def get_data(document: TextDocument, data: str) -> str:
222222
assert await document.get_cache(get_data, "data3") == "3data3"
223223

224224

225-
@pytest.mark.asyncio
225+
@pytest.mark.asyncio()
226226
async def test_document_get_set_cache_with_method_should_work() -> None:
227227
text = """\
228228
first

tests/robotcode/language_server/robotframework/parts/test_discovering.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313

1414
@pytest.mark.usefixtures("protocol")
15-
@pytest.mark.asyncio
15+
@pytest.mark.asyncio()
1616
async def test_workspace_discovery(
1717
regtest: RegTestFixture,
1818
protocol: RobotLanguageServerProtocol,

tests/robotcode/language_server/robotframework/parts/test_document_highlight.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
scope="package",
2626
)
2727
@pytest.mark.usefixtures("protocol")
28-
@pytest.mark.asyncio
28+
@pytest.mark.asyncio()
2929
async def test(
3030
regtest: RegTestFixture,
3131
protocol: RobotLanguageServerProtocol,

tests/robotcode/language_server/robotframework/parts/test_foldingrange.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def generate_foldingrange_test_id(params: Any) -> Any:
6262
ids=generate_foldingrange_test_id,
6363
scope="module",
6464
)
65-
@pytest.mark.asyncio
65+
@pytest.mark.asyncio()
6666
async def test(
6767
regtest: RegTestFixture,
6868
protocol: RobotLanguageServerProtocol,

tests/robotcode/language_server/robotframework/parts/test_goto_definition.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
scope="module",
2727
)
2828
@pytest.mark.usefixtures("protocol")
29-
@pytest.mark.asyncio
29+
@pytest.mark.asyncio()
3030
async def test_definition(
3131
regtest: RegTestFixture,
3232
protocol: RobotLanguageServerProtocol,

tests/robotcode/language_server/robotframework/parts/test_goto_implementation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def split(
5050
scope="module",
5151
)
5252
@pytest.mark.usefixtures("protocol")
53-
@pytest.mark.asyncio
53+
@pytest.mark.asyncio()
5454
async def test_implementation(
5555
regtest: RegTestFixture,
5656
protocol: RobotLanguageServerProtocol,

tests/robotcode/language_server/robotframework/parts/test_hover.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
scope="module",
2727
)
2828
@pytest.mark.usefixtures("protocol")
29-
@pytest.mark.asyncio
29+
@pytest.mark.asyncio()
3030
async def test(
3131
regtest: RegTestFixture,
3232
protocol: RobotLanguageServerProtocol,

tests/robotcode/language_server/robotframework/parts/test_references.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
scope="module",
3030
)
3131
@pytest.mark.usefixtures("protocol")
32-
@pytest.mark.asyncio
32+
@pytest.mark.asyncio()
3333
async def test(
3434
regtest: RegTestFixture,
3535
protocol: RobotLanguageServerProtocol,

0 commit comments

Comments
 (0)