Skip to content

Commit

Permalink
Fix json print
Browse files Browse the repository at this point in the history
  • Loading branch information
jhamon committed Sep 5, 2024
1 parent bc32c17 commit a6aa613
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 15 deletions.
10 changes: 9 additions & 1 deletion pinecone/utils/repr_overrides.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
import json
from datetime import datetime


def custom_serializer(obj):
if isinstance(obj, datetime):
return obj.isoformat()
else:
return str(obj)


def install_json_repr_override(klass):
klass.__repr__ = lambda self: json.dumps(self.to_dict(), indent=4, sort_keys=False)
klass.__repr__ = lambda self: json.dumps(self.to_dict(), indent=4, sort_keys=False, default=custom_serializer)
28 changes: 14 additions & 14 deletions tests/unit/data/test_bulk_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,25 +88,25 @@ def test_no_arguments(self, mocker):

class TestDescribeImport:
def test_describe_import(self, mocker):
# body = """
# {
# "id": "1",
# "records_imported": 1000,
# "uri": "s3://path/to/file.parquet",
# "status": "In Progress",
# "error_mode": "CONTINUE",
# "created_at": "2021-01-01T00:00:00Z",
# "updated_at": "2021-01-01T00:00:00Z",
# "integration": "s3",
# "error_message": ""
# "percent_complete": 43.2
# }
# """
body = """
{
"id": "1",
"records_imported": 1000,
"uri": "s3://path/to/file.parquet",
"status": "In Progress",
"error_mode": "CONTINUE",
"created_at": "2021-01-01T00:00:00Z",
"updated_at": "2021-01-01T00:00:00Z",
"integration": "s3",
"error_message": ""
"percent_complete": 43.2
}
"""
# body = """
# {
# "id": "1",
# }
# """
client = build_client_w_faked_response(mocker, body)

with pytest.warns(UserWarning, match="prerelease"):
Expand Down

0 comments on commit a6aa613

Please sign in to comment.