Skip to content

Commit 48c6d7c

Browse files
authored
Enable ruff PT006/PT007 parametrize tuple rules (#1679)
1 parent c32ebe8 commit 48c6d7c

6 files changed

Lines changed: 41 additions & 39 deletions

File tree

pyproject.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ select = [
1818
"PERF", # Perflint
1919
"PIE", # flake8-pie
2020
"PL", # pylint
21+
"PT006", # pytest-parametrize-names-wrong-type
22+
"PT007", # pytest-parametrize-values-wrong-type
2123
"PTH", # flake8-use-pathlib
2224
"UP", # pyupgrade
2325
"RET", # flake8-return

tests/test__frame_helper.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@
9999

100100

101101
@pytest.mark.parametrize(
102-
"in_bytes, pkt_data, pkt_type",
102+
("in_bytes", "pkt_data", "pkt_type"),
103103
_PLAINTEXT_TESTS,
104104
)
105105
async def test_plaintext_frame_helper(
@@ -132,7 +132,7 @@ async def test_plaintext_frame_helper(
132132

133133

134134
@pytest.mark.parametrize(
135-
"in_bytes, pkt_data, pkt_type",
135+
("in_bytes", "pkt_data", "pkt_type"),
136136
_PLAINTEXT_TESTS,
137137
)
138138
async def test_plaintext_frame_helper_multiple_payloads_single_packet(
@@ -167,7 +167,7 @@ async def test_plaintext_frame_helper_multiple_payloads_single_packet(
167167

168168
@pytest.mark.parametrize(
169169
"byte_type",
170-
(bytes, bytearray, memoryview),
170+
[bytes, bytearray, memoryview],
171171
)
172172
async def test_plaintext_frame_helper_protractor_event_loop(byte_type: Any) -> None:
173173
"""Test the plaintext frame helper with the protractor event loop.
@@ -207,7 +207,7 @@ async def test_plaintext_frame_helper_protractor_event_loop(byte_type: Any) -> N
207207

208208
@pytest.mark.parametrize(
209209
"byte_type",
210-
(bytes, bytearray, memoryview),
210+
[bytes, bytearray, memoryview],
211211
)
212212
async def test_noise_protector_event_loop(byte_type: Any) -> None:
213213
"""Test the noise frame helper with the protractor event loop.
@@ -418,7 +418,7 @@ async def test_noise_mac_in_exception():
418418
]
419419

420420

421-
@pytest.mark.parametrize("val, encoded", VARUINT_TESTCASES)
421+
@pytest.mark.parametrize(("val", "encoded"), VARUINT_TESTCASES)
422422
def test_varuint_to_bytes(val, encoded):
423423
assert varuint_to_bytes(val) == encoded
424424
assert cached_varuint_to_bytes(val) == encoded
@@ -1373,10 +1373,10 @@ async def test_connection_lost_closes_connection_and_logs(
13731373

13741374
@pytest.mark.parametrize(
13751375
("bad_psk", "error"),
1376-
(
1376+
[
13771377
("dGhpc2lzbm90MzJieXRlcw==", "expected base64-encoded 32-byte value"),
13781378
("QRTIErOb/fcE9Ukd/5qA3RGYMn0Y+p06U58SCtOXvPc", "Malformed PSK"),
1379-
),
1379+
],
13801380
)
13811381
async def test_noise_bad_psks(bad_psk: str, error: str) -> None:
13821382
"""Test we raise on bad psks."""

tests/test_client.py

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -666,7 +666,7 @@ async def test_subscribe_states_camera_oversized_done_chunk_does_not_tombstone(
666666

667667

668668
@pytest.mark.parametrize(
669-
"cmd, req",
669+
("cmd", "req"),
670670
[
671671
(dict(key=1), dict(key=1)),
672672
(
@@ -700,7 +700,7 @@ async def test_cover_command_legacy(
700700

701701

702702
@pytest.mark.parametrize(
703-
"cmd, req",
703+
("cmd", "req"),
704704
[
705705
(dict(key=1), dict(key=1)),
706706
(dict(key=1, position=0.5), dict(key=1, has_position=True, position=0.5)),
@@ -723,7 +723,7 @@ async def test_cover_command(
723723

724724

725725
@pytest.mark.parametrize(
726-
"cmd, req",
726+
("cmd", "req"),
727727
[
728728
(dict(key=1), dict(key=1)),
729729
(dict(key=1, state=True), dict(key=1, has_state=True, state=True)),
@@ -759,7 +759,7 @@ async def test_fan_command(
759759

760760

761761
@pytest.mark.parametrize(
762-
"cmd, req",
762+
("cmd", "req"),
763763
[
764764
(dict(key=1), dict(key=1)),
765765
(dict(key=1, state=True), dict(key=1, has_state=True, state=True)),
@@ -822,7 +822,7 @@ async def test_light_command(
822822

823823

824824
@pytest.mark.parametrize(
825-
"cmd, req",
825+
("cmd", "req"),
826826
[
827827
(dict(key=1, state=False), dict(key=1, state=False)),
828828
(dict(key=1, state=True), dict(key=1, state=True)),
@@ -942,7 +942,7 @@ async def test_water_heater_command(
942942

943943

944944
@pytest.mark.parametrize(
945-
"cmd, req",
945+
("cmd", "req"),
946946
[
947947
(
948948
dict(key=1, preset=ClimatePreset.HOME),
@@ -965,7 +965,7 @@ async def test_climate_command_legacy(
965965

966966

967967
@pytest.mark.parametrize(
968-
"cmd, req",
968+
("cmd", "req"),
969969
[
970970
(
971971
dict(key=1, mode=ClimateMode.HEAT),
@@ -1020,7 +1020,7 @@ async def test_climate_command(
10201020

10211021

10221022
@pytest.mark.parametrize(
1023-
"cmd, req",
1023+
("cmd", "req"),
10241024
[
10251025
(dict(key=1, state=0.0), dict(key=1, state=0.0)),
10261026
(dict(key=1, state=100.0), dict(key=1, state=100.0)),
@@ -1036,7 +1036,7 @@ async def test_number_command(
10361036

10371037

10381038
@pytest.mark.parametrize(
1039-
"cmd, req",
1039+
("cmd", "req"),
10401040
[
10411041
(
10421042
dict(key=1, year=2024, month=2, day=29),
@@ -1061,7 +1061,7 @@ async def test_date_command(
10611061

10621062

10631063
@pytest.mark.parametrize(
1064-
"cmd, req",
1064+
("cmd", "req"),
10651065
[
10661066
(
10671067
dict(key=1, hour=12, minute=30, second=30),
@@ -1086,7 +1086,7 @@ async def test_time_command(
10861086

10871087

10881088
@pytest.mark.parametrize(
1089-
"cmd, req",
1089+
("cmd", "req"),
10901090
[
10911091
(
10921092
dict(key=1, epoch_seconds=1735648230),
@@ -1108,7 +1108,7 @@ async def test_datetime_command(
11081108

11091109

11101110
@pytest.mark.parametrize(
1111-
"cmd, req",
1111+
("cmd", "req"),
11121112
[
11131113
(dict(key=1, command=LockCommand.LOCK), dict(key=1, command=LockCommand.LOCK)),
11141114
(
@@ -1132,7 +1132,7 @@ async def test_lock_command(
11321132

11331133

11341134
@pytest.mark.parametrize(
1135-
"cmd, req",
1135+
("cmd", "req"),
11361136
[
11371137
(dict(key=1), dict(key=1)),
11381138
(dict(key=1, position=1.0), dict(key=1, position=1.0, has_position=True)),
@@ -1150,7 +1150,7 @@ async def test_valve_command(
11501150

11511151

11521152
@pytest.mark.parametrize(
1153-
"cmd, req",
1153+
("cmd", "req"),
11541154
[
11551155
(dict(key=1), dict(key=1)),
11561156
(dict(key=1, position=0.5), dict(key=1, has_position=True, position=0.5)),
@@ -1173,7 +1173,7 @@ async def test_valve_command_version_1_1(
11731173

11741174

11751175
@pytest.mark.parametrize(
1176-
"cmd, req",
1176+
("cmd", "req"),
11771177
[
11781178
(dict(key=1, state="One"), dict(key=1, state="One")),
11791179
(dict(key=1, state="Two"), dict(key=1, state="Two")),
@@ -1189,7 +1189,7 @@ async def test_select_command(
11891189

11901190

11911191
@pytest.mark.parametrize(
1192-
"cmd, req",
1192+
("cmd", "req"),
11931193
[
11941194
(
11951195
dict(key=1, command=MediaPlayerCommand.MUTE),
@@ -1225,7 +1225,7 @@ async def test_media_player_command(
12251225

12261226

12271227
@pytest.mark.parametrize(
1228-
"cmd, req",
1228+
("cmd", "req"),
12291229
[
12301230
(dict(key=1), dict(key=1)),
12311231
],
@@ -1240,7 +1240,7 @@ async def test_button_command(
12401240

12411241

12421242
@pytest.mark.parametrize(
1243-
"cmd, req",
1243+
("cmd", "req"),
12441244
[
12451245
(dict(key=1, state=True), dict(key=1, state=True, has_state=True)),
12461246
(dict(key=1, state=False), dict(key=1, state=False, has_state=True)),
@@ -1473,7 +1473,7 @@ async def test_request_image_stream(auth_client: APIClient) -> None:
14731473

14741474

14751475
@pytest.mark.parametrize(
1476-
"cmd, req",
1476+
("cmd", "req"),
14771477
[
14781478
(
14791479
dict(key=1, command=AlarmControlPanelCommand.ARM_AWAY),
@@ -1499,7 +1499,7 @@ async def test_alarm_panel_command(
14991499

15001500

15011501
@pytest.mark.parametrize(
1502-
"cmd, req",
1502+
("cmd", "req"),
15031503
[
15041504
(dict(key=1, state="hello world"), dict(key=1, state="hello world")),
15051505
(dict(key=1, state="goodbye"), dict(key=1, state="goodbye")),
@@ -1515,7 +1515,7 @@ async def test_text_command(
15151515

15161516

15171517
@pytest.mark.parametrize(
1518-
"cmd, req",
1518+
("cmd", "req"),
15191519
[
15201520
(
15211521
dict(key=1, command=UpdateCommand.INSTALL),

tests/test_model.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ class DummyIntEnum(APIIntEnum):
186186

187187

188188
@pytest.mark.parametrize(
189-
"input, output",
189+
("input", "output"),
190190
[
191191
(0, DummyIntEnum.DEFAULT),
192192
(1, DummyIntEnum.MY_VAL),
@@ -203,7 +203,7 @@ def test_api_int_enum_convert(input, output):
203203

204204

205205
@pytest.mark.parametrize(
206-
"input, output",
206+
("input", "output"),
207207
[
208208
([], []),
209209
([1], [DummyIntEnum.MY_VAL]),
@@ -299,7 +299,7 @@ def test_api_version_ord():
299299

300300

301301
@pytest.mark.parametrize(
302-
"model, pb",
302+
("model", "pb"),
303303
[
304304
(DeviceInfo, DeviceInfoResponse),
305305
(BinarySensorInfo, ListEntitiesBinarySensorResponse),
@@ -362,7 +362,7 @@ def test_basic_pb_conversions(model, pb):
362362

363363

364364
@pytest.mark.parametrize(
365-
"state, version, out",
365+
("state", "version", "out"),
366366
[
367367
(CoverState(legacy_state=LegacyCoverState.OPEN), (1, 0), False),
368368
(CoverState(legacy_state=LegacyCoverState.CLOSED), (1, 0), True),
@@ -376,7 +376,7 @@ def test_cover_state_legacy_state(state, version, out):
376376

377377

378378
@pytest.mark.parametrize(
379-
"state, version, out",
379+
("state", "version", "out"),
380380
[
381381
(
382382
ClimateInfo(supports_current_temperature=True),
@@ -415,7 +415,7 @@ def test_climate_info_supported_feature_flags_compat(state, version, out):
415415

416416

417417
@pytest.mark.parametrize(
418-
"state, version, out",
418+
("state", "version", "out"),
419419
[
420420
(ClimateInfo(legacy_supports_away=False), (1, 4), []),
421421
(
@@ -437,7 +437,7 @@ def test_climate_info_supported_presets_compat(state, version, out):
437437

438438

439439
@pytest.mark.parametrize(
440-
"state, version, out",
440+
("state", "version", "out"),
441441
[
442442
(ClimateState(unused_legacy_away=False), (1, 4), ClimatePreset.HOME),
443443
(ClimateState(unused_legacy_away=True), (1, 4), ClimatePreset.AWAY),
@@ -1822,7 +1822,7 @@ def test_event_entity_state_device_id():
18221822

18231823

18241824
@pytest.mark.parametrize(
1825-
"input, output",
1825+
("input", "output"),
18261826
[
18271827
(0, SupportsResponseType.NONE),
18281828
(1, SupportsResponseType.OPTIONAL),

tests/test_reconnect_logic.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ async def on_connect_fail(connect_exception: Exception) -> None:
373373

374374
@pytest.mark.parametrize(
375375
("record", "should_trigger_zeroconf", "expected_state_after_trigger", "log_text"),
376-
(
376+
[
377377
(
378378
DNS_POINTER,
379379
True,
@@ -416,7 +416,7 @@ async def on_connect_fail(connect_exception: Exception) -> None:
416416
ReconnectLogicState.READY,
417417
"received mDNS record",
418418
),
419-
),
419+
],
420420
)
421421
async def test_reconnect_zeroconf(
422422
patchable_api_client: APIClient,

tests/test_util.py

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

99

1010
@pytest.mark.parametrize(
11-
"input, output",
11+
("input", "output"),
1212
[
1313
(0, 0),
1414
(float("inf"), float("inf")),

0 commit comments

Comments
 (0)