Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

➕ ✨ ⚡ replace json with orjson #214

Merged
merged 4 commits into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
8 changes: 4 additions & 4 deletions aries_cloudcontroller/api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

import datetime
import decimal
import json
import mimetypes
import os
import re
Expand All @@ -23,6 +22,7 @@
from typing import Dict, List, Optional, Tuple, Union
from urllib.parse import quote

import orjson
from dateutil.parser import parse
from pydantic import SecretStr

Expand Down Expand Up @@ -389,7 +389,7 @@ def deserialize(
# fetch data from response object
if content_type is None:
try:
data = json.loads(response_text)
data = orjson.loads(response_text)
except ValueError:
data = response_text
elif re.match(
Expand All @@ -400,7 +400,7 @@ def deserialize(
if response_text == "":
data = ""
else:
data = json.loads(response_text)
data = orjson.loads(response_text)
elif re.match(r"^text\/[a-z.+-]+\s*(;|$)", content_type, re.IGNORECASE):
data = response_text
else:
Expand Down Expand Up @@ -500,7 +500,7 @@ def parameters_to_url_query(self, params, collection_formats):
if isinstance(v, (int, float)):
v = str(v)
if isinstance(v, dict):
v = json.dumps(v)
v = orjson.dumps(v).decode()

if k in collection_formats:
collection_format = collection_formats[k]
Expand Down
4 changes: 2 additions & 2 deletions aries_cloudcontroller/models/action_menu_fetch_result.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@

from __future__ import annotations

import json
import pprint
from typing import Any, ClassVar, Dict, List, Optional, Set

import orjson
from pydantic import BaseModel, Field
from typing_extensions import Self

Expand Down Expand Up @@ -46,7 +46,7 @@ def to_json(self) -> str:
@classmethod
def from_json(cls, json_str: str) -> Optional[Self]:
"""Create an instance of ActionMenuFetchResult from a JSON string"""
return cls.from_dict(json.loads(json_str))
return cls.from_dict(orjson.loads(json_str))

def to_dict(self) -> Dict[str, Any]:
"""Return the dictionary representation of the model using alias.
Expand Down
4 changes: 2 additions & 2 deletions aries_cloudcontroller/models/add_proof.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@

from __future__ import annotations

import json
import pprint
from typing import Any, ClassVar, Dict, List, Optional, Set

import orjson
from pydantic import BaseModel
from typing_extensions import Self

Expand Down Expand Up @@ -49,7 +49,7 @@ def to_json(self) -> str:
@classmethod
def from_json(cls, json_str: str) -> Optional[Self]:
"""Create an instance of AddProof from a JSON string"""
return cls.from_dict(json.loads(json_str))
return cls.from_dict(orjson.loads(json_str))

def to_dict(self) -> Dict[str, Any]:
"""Return the dictionary representation of the model using alias.
Expand Down
4 changes: 2 additions & 2 deletions aries_cloudcontroller/models/add_proof_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@

from __future__ import annotations

import json
import pprint
from typing import Any, ClassVar, Dict, List, Optional, Set

import orjson
from pydantic import BaseModel
from typing_extensions import Self

Expand Down Expand Up @@ -45,7 +45,7 @@ def to_json(self) -> str:
@classmethod
def from_json(cls, json_str: str) -> Optional[Self]:
"""Create an instance of AddProofResponse from a JSON string"""
return cls.from_dict(json.loads(json_str))
return cls.from_dict(orjson.loads(json_str))

def to_dict(self) -> Dict[str, Any]:
"""Return the dictionary representation of the model using alias.
Expand Down
4 changes: 2 additions & 2 deletions aries_cloudcontroller/models/admin_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@

from __future__ import annotations

import json
import pprint
from typing import Any, ClassVar, Dict, List, Optional, Set

import orjson
from pydantic import BaseModel, Field
from typing_extensions import Self

Expand Down Expand Up @@ -45,7 +45,7 @@ def to_json(self) -> str:
@classmethod
def from_json(cls, json_str: str) -> Optional[Self]:
"""Create an instance of AdminConfig from a JSON string"""
return cls.from_dict(json.loads(json_str))
return cls.from_dict(orjson.loads(json_str))

def to_dict(self) -> Dict[str, Any]:
"""Return the dictionary representation of the model using alias.
Expand Down
4 changes: 2 additions & 2 deletions aries_cloudcontroller/models/admin_modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@

from __future__ import annotations

import json
import pprint
from typing import Any, ClassVar, Dict, List, Optional, Set

import orjson
from pydantic import BaseModel, Field, StrictStr
from typing_extensions import Self

Expand Down Expand Up @@ -47,7 +47,7 @@ def to_json(self) -> str:
@classmethod
def from_json(cls, json_str: str) -> Optional[Self]:
"""Create an instance of AdminModules from a JSON string"""
return cls.from_dict(json.loads(json_str))
return cls.from_dict(orjson.loads(json_str))

def to_dict(self) -> Dict[str, Any]:
"""Return the dictionary representation of the model using alias.
Expand Down
4 changes: 2 additions & 2 deletions aries_cloudcontroller/models/admin_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@

from __future__ import annotations

import json
import pprint
from typing import Any, ClassVar, Dict, List, Optional, Set

import orjson
from pydantic import BaseModel, Field, StrictStr
from typing_extensions import Self

Expand Down Expand Up @@ -50,7 +50,7 @@ def to_json(self) -> str:
@classmethod
def from_json(cls, json_str: str) -> Optional[Self]:
"""Create an instance of AdminStatus from a JSON string"""
return cls.from_dict(json.loads(json_str))
return cls.from_dict(orjson.loads(json_str))

def to_dict(self) -> Dict[str, Any]:
"""Return the dictionary representation of the model using alias.
Expand Down
4 changes: 2 additions & 2 deletions aries_cloudcontroller/models/admin_status_liveliness.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@

from __future__ import annotations

import json
import pprint
from typing import Any, ClassVar, Dict, List, Optional, Set

import orjson
from pydantic import BaseModel, Field, StrictBool
from typing_extensions import Self

Expand Down Expand Up @@ -45,7 +45,7 @@ def to_json(self) -> str:
@classmethod
def from_json(cls, json_str: str) -> Optional[Self]:
"""Create an instance of AdminStatusLiveliness from a JSON string"""
return cls.from_dict(json.loads(json_str))
return cls.from_dict(orjson.loads(json_str))

def to_dict(self) -> Dict[str, Any]:
"""Return the dictionary representation of the model using alias.
Expand Down
4 changes: 2 additions & 2 deletions aries_cloudcontroller/models/admin_status_readiness.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@

from __future__ import annotations

import json
import pprint
from typing import Any, ClassVar, Dict, List, Optional, Set

import orjson
from pydantic import BaseModel, Field, StrictBool
from typing_extensions import Self

Expand Down Expand Up @@ -45,7 +45,7 @@ def to_json(self) -> str:
@classmethod
def from_json(cls, json_str: str) -> Optional[Self]:
"""Create an instance of AdminStatusReadiness from a JSON string"""
return cls.from_dict(json.loads(json_str))
return cls.from_dict(orjson.loads(json_str))

def to_dict(self) -> Dict[str, Any]:
"""Return the dictionary representation of the model using alias.
Expand Down
4 changes: 2 additions & 2 deletions aries_cloudcontroller/models/aml_record.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@

from __future__ import annotations

import json
import pprint
from typing import Any, ClassVar, Dict, List, Optional, Set

import orjson
from pydantic import BaseModel, Field, StrictStr
from typing_extensions import Self

Expand Down Expand Up @@ -47,7 +47,7 @@ def to_json(self) -> str:
@classmethod
def from_json(cls, json_str: str) -> Optional[Self]:
"""Create an instance of AMLRecord from a JSON string"""
return cls.from_dict(json.loads(json_str))
return cls.from_dict(orjson.loads(json_str))

def to_dict(self) -> Dict[str, Any]:
"""Return the dictionary representation of the model using alias.
Expand Down
4 changes: 2 additions & 2 deletions aries_cloudcontroller/models/anon_creds_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@

from __future__ import annotations

import json
import pprint
from typing import Any, ClassVar, Dict, List, Optional, Set

import orjson
from pydantic import BaseModel, Field, StrictStr
from typing_extensions import Self

Expand Down Expand Up @@ -54,7 +54,7 @@ def to_json(self) -> str:
@classmethod
def from_json(cls, json_str: str) -> Optional[Self]:
"""Create an instance of AnonCredsSchema from a JSON string"""
return cls.from_dict(json.loads(json_str))
return cls.from_dict(orjson.loads(json_str))

def to_dict(self) -> Dict[str, Any]:
"""Return the dictionary representation of the model using alias.
Expand Down
4 changes: 2 additions & 2 deletions aries_cloudcontroller/models/attach_decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@

from __future__ import annotations

import json
import pprint
import re
from typing import Any, ClassVar, Dict, List, Optional, Set

import orjson
from pydantic import BaseModel, Field, StrictInt, StrictStr, field_validator
from typing_extensions import Annotated, Self

Expand Down Expand Up @@ -87,7 +87,7 @@ def to_json(self) -> str:
@classmethod
def from_json(cls, json_str: str) -> Optional[Self]:
"""Create an instance of AttachDecorator from a JSON string"""
return cls.from_dict(json.loads(json_str))
return cls.from_dict(orjson.loads(json_str))

def to_dict(self) -> Dict[str, Any]:
"""Return the dictionary representation of the model using alias.
Expand Down
4 changes: 2 additions & 2 deletions aries_cloudcontroller/models/attach_decorator_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@

from __future__ import annotations

import json
import pprint
import re
from typing import Any, ClassVar, Dict, List, Optional, Set, Union

import orjson
from pydantic import BaseModel, Field, StrictStr, field_validator
from typing_extensions import Annotated, Self

Expand Down Expand Up @@ -88,7 +88,7 @@ def to_json(self) -> str:
@classmethod
def from_json(cls, json_str: str) -> Optional[Self]:
"""Create an instance of AttachDecoratorData from a JSON string"""
return cls.from_dict(json.loads(json_str))
return cls.from_dict(orjson.loads(json_str))

def to_dict(self) -> Dict[str, Any]:
"""Return the dictionary representation of the model using alias.
Expand Down
4 changes: 2 additions & 2 deletions aries_cloudcontroller/models/attach_decorator_data1_jws.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@

from __future__ import annotations

import json
import pprint
import re
from typing import Any, ClassVar, Dict, List, Optional, Set

import orjson
from pydantic import BaseModel, Field, field_validator
from typing_extensions import Annotated, Self

Expand Down Expand Up @@ -70,7 +70,7 @@ def to_json(self) -> str:
@classmethod
def from_json(cls, json_str: str) -> Optional[Self]:
"""Create an instance of AttachDecoratorData1JWS from a JSON string"""
return cls.from_dict(json.loads(json_str))
return cls.from_dict(orjson.loads(json_str))

def to_dict(self) -> Dict[str, Any]:
"""Return the dictionary representation of the model using alias.
Expand Down
4 changes: 2 additions & 2 deletions aries_cloudcontroller/models/attach_decorator_data_jws.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@

from __future__ import annotations

import json
import pprint
import re
from typing import Any, ClassVar, Dict, List, Optional, Set

import orjson
from pydantic import BaseModel, Field, field_validator
from typing_extensions import Annotated, Self

Expand Down Expand Up @@ -86,7 +86,7 @@ def to_json(self) -> str:
@classmethod
def from_json(cls, json_str: str) -> Optional[Self]:
"""Create an instance of AttachDecoratorDataJWS from a JSON string"""
return cls.from_dict(json.loads(json_str))
return cls.from_dict(orjson.loads(json_str))

def to_dict(self) -> Dict[str, Any]:
"""Return the dictionary representation of the model using alias.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@

from __future__ import annotations

import json
import pprint
import re
from typing import Any, ClassVar, Dict, List, Optional, Set

import orjson
from pydantic import BaseModel, Field, field_validator
from typing_extensions import Annotated, Self

Expand Down Expand Up @@ -60,7 +60,7 @@ def to_json(self) -> str:
@classmethod
def from_json(cls, json_str: str) -> Optional[Self]:
"""Create an instance of AttachDecoratorDataJWSHeader from a JSON string"""
return cls.from_dict(json.loads(json_str))
return cls.from_dict(orjson.loads(json_str))

def to_dict(self) -> Dict[str, Any]:
"""Return the dictionary representation of the model using alias.
Expand Down
4 changes: 2 additions & 2 deletions aries_cloudcontroller/models/attachment_def.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@

from __future__ import annotations

import json
import pprint
from typing import Any, ClassVar, Dict, List, Optional, Set

import orjson
from pydantic import BaseModel, Field, StrictStr, field_validator
from typing_extensions import Self

Expand Down Expand Up @@ -58,7 +58,7 @@ def to_json(self) -> str:
@classmethod
def from_json(cls, json_str: str) -> Optional[Self]:
"""Create an instance of AttachmentDef from a JSON string"""
return cls.from_dict(json.loads(json_str))
return cls.from_dict(orjson.loads(json_str))

def to_dict(self) -> Dict[str, Any]:
"""Return the dictionary representation of the model using alias.
Expand Down
Loading