Skip to content

Commit

Permalink
➕ ✨ ⚡ replace json with orjson
Browse files Browse the repository at this point in the history
  • Loading branch information
ff137 committed Oct 28, 2024
1 parent 9303230 commit 2315a80
Show file tree
Hide file tree
Showing 355 changed files with 712 additions and 711 deletions.
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,7 @@

import datetime
import decimal
import json
import orjson
import mimetypes
import os
import re
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,7 +14,7 @@

from __future__ import annotations

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

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,7 +14,7 @@

from __future__ import annotations

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

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,7 +14,7 @@

from __future__ import annotations

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

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,7 +14,7 @@

from __future__ import annotations

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

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,7 +14,7 @@

from __future__ import annotations

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

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,7 +14,7 @@

from __future__ import annotations

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

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,7 +14,7 @@

from __future__ import annotations

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

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,7 +14,7 @@

from __future__ import annotations

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

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,7 +14,7 @@

from __future__ import annotations

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

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,7 +14,7 @@

from __future__ import annotations

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

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,7 +14,7 @@

from __future__ import annotations

import json
import orjson
import pprint
import re
from typing import Any, ClassVar, Dict, List, Optional, Set
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,7 +14,7 @@

from __future__ import annotations

import json
import orjson
import pprint
import re
from typing import Any, ClassVar, Dict, List, Optional, Set, Union
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,7 +14,7 @@

from __future__ import annotations

import json
import orjson
import pprint
import re
from typing import Any, ClassVar, Dict, List, Optional, Set
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,7 +14,7 @@

from __future__ import annotations

import json
import orjson
import pprint
import re
from typing import Any, ClassVar, Dict, List, Optional, Set
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,7 +14,7 @@

from __future__ import annotations

import json
import orjson
import pprint
import re
from typing import Any, ClassVar, Dict, List, Optional, Set
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,7 +14,7 @@

from __future__ import annotations

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

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
4 changes: 2 additions & 2 deletions aries_cloudcontroller/models/attribute_mime_types_result.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

from __future__ import annotations

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

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 AttributeMimeTypesResult 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/claim_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

from __future__ import annotations

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

Expand Down Expand Up @@ -59,7 +59,7 @@ def to_json(self) -> str:
@classmethod
def from_json(cls, json_str: str) -> Optional[Self]:
"""Create an instance of ClaimFormat 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,7 +14,7 @@

from __future__ import annotations

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

Expand Down Expand Up @@ -48,7 +48,7 @@ def to_json(self) -> str:
@classmethod
def from_json(cls, json_str: str) -> Optional[Self]:
"""Create an instance of ClearPendingRevocationsRequest 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/configurable_write_ledgers.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

from __future__ import annotations

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

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 ConfigurableWriteLedgers 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

0 comments on commit 2315a80

Please sign in to comment.