@@ -345,11 +345,13 @@ class TestParseWriteReplicasFromEnvVar:
345
345
346
346
def test_parse_new_array_format (self ):
347
347
"""Test parsing new array format."""
348
- env_var = json .dumps ([
349
- {"api_url" : "https://api.example.com" , "api_key" : "key1" },
350
- {"api_url" : "https://api.example.com" , "api_key" : "key2" },
351
- {"api_url" : "https://api.example.com" , "api_key" : "key3" },
352
- ])
348
+ env_var = json .dumps (
349
+ [
350
+ {"api_url" : "https://api.example.com" , "api_key" : "key1" },
351
+ {"api_url" : "https://api.example.com" , "api_key" : "key2" },
352
+ {"api_url" : "https://api.example.com" , "api_key" : "key3" },
353
+ ]
354
+ )
353
355
354
356
with patch .dict (
355
357
os .environ , {"LANGSMITH_ENDPOINT" : "" , "LANGCHAIN_ENDPOINT" : "" }, clear = True
@@ -396,10 +398,12 @@ def test_parse_object_format(self):
396
398
def test_parse_url_trailing_slash_removal (self ):
397
399
"""Test that trailing slashes are removed from URLs."""
398
400
# Test with new array format
399
- env_var = json .dumps ([
400
- {"api_url" : "https://api.example.com/" , "api_key" : "key1" },
401
- {"api_url" : "https://other.example.com/path/" , "api_key" : "key2" },
402
- ])
401
+ env_var = json .dumps (
402
+ [
403
+ {"api_url" : "https://api.example.com/" , "api_key" : "key1" },
404
+ {"api_url" : "https://other.example.com/path/" , "api_key" : "key2" },
405
+ ]
406
+ )
403
407
404
408
with patch .dict (
405
409
os .environ , {"LANGSMITH_ENDPOINT" : "" , "LANGCHAIN_ENDPOINT" : "" }, clear = True
@@ -416,9 +420,11 @@ def test_parse_url_trailing_slash_removal(self):
416
420
assert "https://other.example.com/path/" not in urls
417
421
418
422
# Test with object format
419
- env_var2 = json .dumps ({
420
- "https://object.example.com/" : "object-key" ,
421
- })
423
+ env_var2 = json .dumps (
424
+ {
425
+ "https://object.example.com/" : "object-key" ,
426
+ }
427
+ )
422
428
423
429
with patch .dict (
424
430
os .environ , {"LANGSMITH_ENDPOINT" : "" , "LANGCHAIN_ENDPOINT" : "" }, clear = True
@@ -505,14 +511,16 @@ def test_parse_invalid_json(self):
505
511
506
512
def test_parse_new_array_format_invalid_items (self ):
507
513
"""Test parsing new array format with invalid items."""
508
- env_var = json .dumps ([
509
- {"api_url" : "https://valid.example.com" , "api_key" : "valid-key" },
510
- "invalid-string-item" ,
511
- {"api_url" : "https://missing-key.example.com" }, # missing api_key
512
- {"api_key" : "missing-url-key" }, # missing api_url
513
- {"api_url" : 123 , "api_key" : "invalid-url-type" }, # invalid api_url type
514
- {"api_url" : "https://invalid-key-type.example.com" , "api_key" : 456 },
515
- ])
514
+ env_var = json .dumps (
515
+ [
516
+ {"api_url" : "https://valid.example.com" , "api_key" : "valid-key" },
517
+ "invalid-string-item" ,
518
+ {"api_url" : "https://missing-key.example.com" }, # missing api_key
519
+ {"api_key" : "missing-url-key" }, # missing api_url
520
+ {"api_url" : 123 , "api_key" : "invalid-url-type" }, # invalid api_url type
521
+ {"api_url" : "https://invalid-key-type.example.com" , "api_key" : 456 },
522
+ ]
523
+ )
516
524
517
525
with patch .dict (
518
526
os .environ , {"LANGSMITH_ENDPOINT" : "" , "LANGCHAIN_ENDPOINT" : "" }, clear = True
@@ -677,10 +685,10 @@ def test_baggage_parsing_tuple_format(self):
677
685
678
686
from langsmith .run_trees import _Baggage
679
687
680
- # tuple format: [ project_name, updates]
688
+ # tuple format: ( project_name, updates)
681
689
tuple_replicas = [
682
- [ "replica-project-1" , {"environment" : "staging" }] ,
683
- [ "replica-project-2" , None ] ,
690
+ ( "replica-project-1" , {"environment" : "staging" }) ,
691
+ ( "replica-project-2" , None ) ,
684
692
]
685
693
686
694
baggage_value = (
@@ -745,7 +753,7 @@ def test_baggage_parsing_mixed_format(self):
745
753
746
754
# Mixed format: both tuple and new
747
755
mixed_replicas = [
748
- [ "tuple-project" , {"tuple" : "true" }] , # tuple format
756
+ ( "tuple-project" , {"tuple" : "true" }) , # tuple format
749
757
{
750
758
"api_url" : "https://new.example.com" ,
751
759
"api_key" : "new-key" ,
0 commit comments