Skip to content

Commit e22394d

Browse files
committed
enable ruff PT
1 parent dbf612a commit e22394d

6 files changed

Lines changed: 16 additions & 16 deletions

File tree

python/lib/sift_client/.ruff.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ select = [
3939
"LOG", # flake8-logging - logging best practices
4040

4141
# Tests
42-
# "PT", # flake8-pytest-style - pytest best practices # TODO: FD-59
42+
"PT", # flake8-pytest-style - pytest best practices
4343

4444
]
4545

python/lib/sift_client/_tests/resources/test_calculated_channels.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ def test_calculated_channel(calculated_channels_api_sync):
5252
return calculated_channels[0]
5353

5454

55-
@pytest.fixture(scope="function")
5655
def new_calculated_channel(calculated_channels_api_sync, sift_client):
5756
"""Create a test calculated channel for update tests."""
5857
from datetime import datetime, timezone
@@ -450,7 +449,9 @@ async def test_update_with_invalid_expression(
450449
assert updated_calc_channel.expression == "invalid_expression"
451450
except Exception as e:
452451
# If server validates and rejects, that's also acceptable behavior
453-
assert "expression" in str(e).lower() or "invalid" in str(e).lower()
452+
assert ( # noqa: PT017
453+
"expression" in str(e).lower() or "invalid" in str(e).lower()
454+
)
454455
finally:
455456
await calculated_channels_api_async.archive(new_calculated_channel.id_)
456457

python/lib/sift_client/_tests/resources/test_ingestion.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ def test_client_binding(sift_client):
2929
assert sift_client.async_.ingestion
3030

3131

32-
@pytest.fixture(scope="function")
3332
def test_run(sift_client: SiftClient):
3433
"""Create a test run for ingestion tests."""
3534
run = sift_client.runs.create(

python/lib/sift_client/_tests/resources/test_rules.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ def test_rule(rules_api_sync):
5454
return rules[0]
5555

5656

57-
@pytest.fixture(scope="function")
5857
def new_rule(rules_api_sync, sift_client):
5958
"""Create a test rule for update tests."""
6059
from datetime import datetime, timezone
@@ -558,7 +557,9 @@ async def test_update_with_invalid_expression(self, rules_api_async, new_rule):
558557
assert updated_rule.expression == "invalid_expression"
559558
except Exception as e:
560559
# If server validates and rejects, that's also acceptable behavior
561-
assert "expression" in str(e).lower() or "invalid" in str(e).lower()
560+
assert ( # noqa: PT017
561+
"expression" in str(e).lower() or "invalid" in str(e).lower()
562+
)
562563
finally:
563564
await rules_api_async.archive(new_rule.id_)
564565

python/lib/sift_client/_tests/resources/test_runs.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ def test_run(runs_api_sync):
4646
return runs[0]
4747

4848

49-
@pytest.fixture(scope="function")
5049
def new_run(runs_api_sync):
5150
"""Create a test run for update tests."""
5251
run_name = f"test_run_update_{datetime.now(timezone.utc).isoformat()}"

python/lib/sift_client/_tests/sift_types/test_base.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -288,18 +288,18 @@ def test_multiple_nested_fields_same_parent(self):
288288

289289
def test_validation_error_on_invalid_helper_field(self):
290290
"""Test that MappingHelper validation catches mismatched fields."""
291-
with pytest.raises(ValueError, match="MappingHelper created for"):
292291

293-
class InvalidModel(ModelCreate[CreateCalculatedChannelRequest]):
294-
name: str
292+
class InvalidModel(ModelCreate[CreateCalculatedChannelRequest]):
293+
name: str
295294

296-
_to_proto_helpers: ClassVar[dict[str, MappingHelper]] = {
297-
"nonexistent_field": MappingHelper(proto_attr_path="some.path"),
298-
}
295+
_to_proto_helpers: ClassVar[dict[str, MappingHelper]] = {
296+
"nonexistent_field": MappingHelper(proto_attr_path="some.path"),
297+
}
299298

300-
def _get_proto_class(self):
301-
return CreateCalculatedChannelRequest
299+
def _get_proto_class(self):
300+
return CreateCalculatedChannelRequest
302301

302+
with pytest.raises(ValueError, match="MappingHelper created for"):
303303
# This should raise during __init__
304304
InvalidModel(name="test")
305305

@@ -495,7 +495,7 @@ def _from_proto(cls, proto, sift_client=None):
495495
model = TestModel(name="test")
496496

497497
# Should not be able to modify frozen model
498-
with pytest.raises(Exception): # Pydantic raises ValidationError # noqa: B017
498+
with pytest.raises(Exception): # noqa: B017, PT011
499499
model.name = "new_name"
500500

501501

0 commit comments

Comments
 (0)