@@ -25,24 +25,18 @@ class TestNullIdRejection:
2525 def test_request_rejects_null_id (self ) -> None :
2626 """JSONRPCRequest correctly rejects null id."""
2727 with pytest .raises (ValidationError ):
28- JSONRPCRequest .model_validate (
29- {"jsonrpc" : "2.0" , "method" : "initialize" , "id" : None }
30- )
28+ JSONRPCRequest .model_validate ({"jsonrpc" : "2.0" , "method" : "initialize" , "id" : None })
3129
3230 def test_notification_rejects_id_field (self ) -> None :
3331 """JSONRPCNotification must not accept messages with an 'id' field."""
3432 with pytest .raises (ValidationError , match = "must not include an 'id' field" ):
35- JSONRPCNotification .model_validate (
36- {"jsonrpc" : "2.0" , "method" : "initialize" , "id" : None }
37- )
33+ JSONRPCNotification .model_validate ({"jsonrpc" : "2.0" , "method" : "initialize" , "id" : None })
3834
3935 def test_notification_rejects_any_id_value (self ) -> None :
4036 """Notification rejects 'id' regardless of value — null, int, or str."""
4137 for id_value in [None , 0 , 1 , "" , "abc" ]:
4238 with pytest .raises (ValidationError ):
43- JSONRPCNotification .model_validate (
44- {"jsonrpc" : "2.0" , "method" : "test" , "id" : id_value }
45- )
39+ JSONRPCNotification .model_validate ({"jsonrpc" : "2.0" , "method" : "test" , "id" : id_value })
4640
4741 def test_message_adapter_rejects_null_id (self ) -> None :
4842 """JSONRPCMessage union must not accept ``"id": null``."""
@@ -58,9 +52,7 @@ def test_message_adapter_rejects_null_id_json(self) -> None:
5852
5953 def test_valid_notification_still_works (self ) -> None :
6054 """A valid notification (no 'id' field at all) must still parse fine."""
61- msg = JSONRPCNotification .model_validate (
62- {"jsonrpc" : "2.0" , "method" : "notifications/initialized" }
63- )
55+ msg = JSONRPCNotification .model_validate ({"jsonrpc" : "2.0" , "method" : "notifications/initialized" })
6456 assert msg .method == "notifications/initialized"
6557
6658 def test_valid_notification_with_params (self ) -> None :
@@ -73,16 +65,12 @@ def test_valid_notification_with_params(self) -> None:
7365
7466 def test_valid_request_with_string_id (self ) -> None :
7567 """A valid request with a string id still works."""
76- msg = JSONRPCRequest .model_validate (
77- {"jsonrpc" : "2.0" , "method" : "initialize" , "id" : "abc-123" }
78- )
68+ msg = JSONRPCRequest .model_validate ({"jsonrpc" : "2.0" , "method" : "initialize" , "id" : "abc-123" })
7969 assert msg .id == "abc-123"
8070
8171 def test_valid_request_with_int_id (self ) -> None :
8272 """A valid request with an integer id still works."""
83- msg = JSONRPCRequest .model_validate (
84- {"jsonrpc" : "2.0" , "method" : "initialize" , "id" : 42 }
85- )
73+ msg = JSONRPCRequest .model_validate ({"jsonrpc" : "2.0" , "method" : "initialize" , "id" : 42 })
8674 assert msg .id == 42
8775
8876 def test_message_adapter_parses_valid_request (self ) -> None :
0 commit comments