Skip to content
Open
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .openapi-generator/FILES
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ sdk/open_api/models/side.py
sdk/open_api/models/spot_execution.py
sdk/open_api/models/spot_execution_list.py
sdk/open_api/models/spot_market_definition.py
sdk/open_api/models/spot_trade_bust.py
sdk/open_api/models/spot_trade_bust_list.py
sdk/open_api/models/tier_type.py
sdk/open_api/models/time_in_force.py
sdk/open_api/models/wallet_configuration.py
Expand Down
10 changes: 10 additions & 0 deletions sdk/async_api/market_spot_trade_bust_update_payload.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from __future__ import annotations
from typing import Any, List, Dict, Optional
from pydantic import BaseModel, Field
from sdk.async_api.channel_data_message_type import ChannelDataMessageType
from sdk.async_api.spot_trade_bust import SpotTradeBust
class MarketSpotTradeBustUpdatePayload(BaseModel):
type: ChannelDataMessageType = Field(description='''Message type for channel data updates''')
timestamp: float = Field(description='''Update timestamp (milliseconds)''')
channel: str = Field(description='''Channel pattern for market spot trade busts''')
data: List[SpotTradeBust] = Field()
Comment on lines +2 to +10
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick | 🔵 Trivial

Use built-in generics in this new payload model.

Ruff is already flagging UP035 here. With the repo's Python 3.12 baseline, list[SpotTradeBust] should replace List[SpotTradeBust] in new code.

♻️ Minimal cleanup
-from typing import Any, List, Dict, Optional
 from pydantic import BaseModel, Field
 from sdk.async_api.channel_data_message_type import ChannelDataMessageType
 from sdk.async_api.spot_trade_bust import SpotTradeBust
 class MarketSpotTradeBustUpdatePayload(BaseModel): 
   type: ChannelDataMessageType = Field(description='''Message type for channel data updates''')
   timestamp: float = Field(description='''Update timestamp (milliseconds)''')
   channel: str = Field(description='''Channel pattern for market spot trade busts''')
-  data: List[SpotTradeBust] = Field()
+  data: list[SpotTradeBust] = Field()

As per coding guidelines, "Require Python 3.12+ for runtime and Python 3.10 for type checking with strict mypy configuration".

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
from typing import Any, List, Dict, Optional
from pydantic import BaseModel, Field
from sdk.async_api.channel_data_message_type import ChannelDataMessageType
from sdk.async_api.spot_trade_bust import SpotTradeBust
class MarketSpotTradeBustUpdatePayload(BaseModel):
type: ChannelDataMessageType = Field(description='''Message type for channel data updates''')
timestamp: float = Field(description='''Update timestamp (milliseconds)''')
channel: str = Field(description='''Channel pattern for market spot trade busts''')
data: List[SpotTradeBust] = Field()
from pydantic import BaseModel, Field
from sdk.async_api.channel_data_message_type import ChannelDataMessageType
from sdk.async_api.spot_trade_bust import SpotTradeBust
class MarketSpotTradeBustUpdatePayload(BaseModel):
type: ChannelDataMessageType = Field(description='''Message type for channel data updates''')
timestamp: float = Field(description='''Update timestamp (milliseconds)''')
channel: str = Field(description='''Channel pattern for market spot trade busts''')
data: list[SpotTradeBust] = Field()
🧰 Tools
🪛 Ruff (0.15.5)

[warning] 2-2: typing.List is deprecated, use list instead

(UP035)


[warning] 2-2: typing.Dict is deprecated, use dict instead

(UP035)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@sdk/async_api/market_spot_trade_bust_update_payload.py` around lines 2 - 10,
Replace the typing.List usage with Python 3.12 built-in generics and clean up
unused typing imports: change the type annotation for
MarketSpotTradeBustUpdatePayload.data from List[SpotTradeBust] to
list[SpotTradeBust], remove the now-unused List (and any other unused imports
like Any/Dict/Optional) from the top-of-file imports, and keep the rest of the
model (fields type names and Field(...) usage) unchanged.

48 changes: 48 additions & 0 deletions sdk/async_api/spot_trade_bust.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
from __future__ import annotations
from typing import Any, Dict, Optional
from pydantic import model_serializer, model_validator, BaseModel, Field
from sdk.async_api.side import Side
class SpotTradeBust(BaseModel):
symbol: str = Field(description='''Trading symbol (e.g., BTCRUSDPERP, WETHRUSD)''')
account_id: int = Field(alias='''accountId''')
counterparty_account_id: int = Field(alias='''counterpartyAccountId''')
qty: str = Field()
side: Side = Field(description='''Order side (B = Buy/Bid, A = Ask/Sell)''')
price: str = Field()
reason: str = Field(description='''Hex-encoded revert reason bytes''')
timestamp: int = Field()
transaction_hash: str = Field(description='''Transaction hash''', alias='''transactionHash''')
additional_properties: Optional[dict[str, Any]] = Field(default=None, exclude=True)
Comment on lines +3 to +15
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

# First, let's locate and examine the async spot trade bust file
find . -name "spot_trade_bust.py" -type f

Repository: Reya-Labs/reya-python-sdk

Length of output: 144


🏁 Script executed:

# Now let's examine the async model file to see lines 3-15 and the full file
cat -n sdk/async_api/spot_trade_bust.py | head -50

Repository: Reya-Labs/reya-python-sdk

Length of output: 2819


🏁 Script executed:

# Let's check the OpenAPI counterpart for comparison
cat -n sdk/open_api/models/spot_trade_bust.py | head -80

Repository: Reya-Labs/reya-python-sdk

Length of output: 3737


🏁 Script executed:

# Check if model_config is used elsewhere in the async_api directory
rg "model_config\s*=" sdk/async_api/ -A 2

Repository: Reya-Labs/reya-python-sdk

Length of output: 51


🏁 Script executed:

# Let's verify Pydantic v2 behavior with aliases and populate_by_name
python3 << 'EOF'
from pydantic import BaseModel, Field, ConfigDict

# Test case 1: Without populate_by_name (like the async model)
class ModelWithoutPopulate(BaseModel):
    account_id: int = Field(alias='accountId')

# Test case 2: With populate_by_name (like the OpenAPI model)
class ModelWithPopulate(BaseModel):
    model_config = ConfigDict(populate_by_name=True)
    account_id: int = Field(alias='accountId')

print("Test 1: Without populate_by_name")
try:
    m1 = ModelWithoutPopulate(account_id=123)
    print(f"  Success: {m1}")
except Exception as e:
    print(f"  Failed: {type(e).__name__}: {e}")

try:
    m1 = ModelWithoutPopulate(accountId=123)
    print(f"  Success with alias: {m1}")
except Exception as e:
    print(f"  Failed with alias: {type(e).__name__}: {e}")

print("\nTest 2: With populate_by_name")
try:
    m2 = ModelWithPopulate(account_id=123)
    print(f"  Success: {m2}")
except Exception as e:
    print(f"  Failed: {type(e).__name__}: {e}")

try:
    m2 = ModelWithPopulate(accountId=123)
    print(f"  Success with alias: {m2}")
except Exception as e:
    print(f"  Failed with alias: {type(e).__name__}: {e}")
EOF

Repository: Reya-Labs/reya-python-sdk

Length of output: 472


🏁 Script executed:

# Check if there are any existing usages of SpotTradeBust in async_api that might reveal the issue
rg "SpotTradeBust" sdk/async_api/ -B 2 -A 5

Repository: Reya-Labs/reya-python-sdk

Length of output: 2707


🏁 Script executed:

# Check line length to verify it complies with the 120 character limit
python3 << 'EOF'
with open('sdk/async_api/spot_trade_bust.py', 'r') as f:
    lines = f.readlines()
    for i, line in enumerate(lines[2:16], start=3):  # lines 3-15
        line_len = len(line.rstrip('\n'))
        status = "OK" if line_len <= 120 else "EXCEEDS"
        print(f"Line {i}: {line_len:3d} chars {status}")
        if line_len > 120:
            print(f"  Content: {line.rstrip()}")
EOF

Repository: Reya-Labs/reya-python-sdk

Length of output: 369


Add populate_by_name=True to enable snake_case field construction.

This model has aliased fields (accountId, counterpartyAccountId, transactionHash) but lacks populate_by_name in its config, so SpotTradeBust(account_id=..., transaction_hash=...) will fail even though the class exposes snake_case attributes. The OpenAPI counterpart already enables this, creating an inconsistency.

🔧 Suggested fix
-from pydantic import model_serializer, model_validator, BaseModel, Field
+from pydantic import ConfigDict, model_serializer, model_validator, BaseModel, Field
 from sdk.async_api.side import Side
 class SpotTradeBust(BaseModel): 
+  model_config = ConfigDict(populate_by_name=True)
   symbol: str = Field(description='''Trading symbol (e.g., BTCRUSDPERP, WETHRUSD)''')
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@sdk/async_api/spot_trade_bust.py` around lines 3 - 15, The SpotTradeBust
Pydantic model exposes snake_case attributes but lacks a Pydantic v2 config to
allow construction using those names; add a model_config = {"populate_by_name":
True} to the SpotTradeBust class so callers can instantiate with account_id,
counterparty_account_id, transaction_hash (and existing alias fields still
function). This change should be made on the SpotTradeBust class (the BaseModel
subclass) alongside the existing fields (symbol, account_id/accountId alias,
counterparty_account_id/counterpartyAccountId alias,
transaction_hash/transactionHash alias).


@model_serializer(mode='wrap')
def custom_serializer(self, handler):
serialized_self = handler(self)
additional_properties = getattr(self, "additional_properties")
if additional_properties is not None:
for key, value in additional_properties.items():
# Never overwrite existing values, to avoid clashes
if not key in serialized_self:
serialized_self[key] = value

return serialized_self

@model_validator(mode='before')
@classmethod
def unwrap_additional_properties(cls, data):
if not isinstance(data, dict):
data = data.model_dump()
json_properties = list(data.keys())
known_object_properties = ['symbol', 'account_id', 'counterparty_account_id', 'qty', 'side', 'price', 'reason', 'timestamp', 'transaction_hash', 'additional_properties']
unknown_object_properties = [element for element in json_properties if element not in known_object_properties]
# Ignore attempts that validate regular models, only when unknown input is used we add unwrap extensions
if len(unknown_object_properties) == 0:
return data

known_json_properties = ['symbol', 'accountId', 'counterpartyAccountId', 'qty', 'side', 'price', 'reason', 'timestamp', 'transactionHash', 'additionalProperties']
additional_properties = data.get('additional_properties', {})
for obj_key in unknown_object_properties:
if not known_json_properties.__contains__(obj_key):
additional_properties[obj_key] = data.pop(obj_key, None)
data['additional_properties'] = additional_properties
return data
Comment on lines +29 to +47
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Guard the pre-validator against non-model inputs.

unwrap_additional_properties currently assumes every non-dict input has model_dump(). None, scalars, or lists will raise AttributeError, and additional_properties=None will raise TypeError as soon as an unknown key is merged, so malformed payloads bypass normal validation errors.

🔧 Suggested fix
   `@model_validator`(mode='before')
   `@classmethod`
-  def unwrap_additional_properties(cls, data):
-    if not isinstance(data, dict):
-      data = data.model_dump()
+  def unwrap_additional_properties(cls, data: Any) -> Any:
+    if isinstance(data, BaseModel):
+      data = data.model_dump()
+    elif not isinstance(data, dict):
+      return data
     json_properties = list(data.keys())
     known_object_properties = ['symbol', 'account_id', 'counterparty_account_id', 'qty', 'side', 'price', 'reason', 'timestamp', 'transaction_hash', 'additional_properties']
     unknown_object_properties = [element for element in json_properties if element not in known_object_properties]
     # Ignore attempts that validate regular models, only when unknown input is used we add unwrap extensions
     if len(unknown_object_properties) == 0: 
       return data
   
     known_json_properties = ['symbol', 'accountId', 'counterpartyAccountId', 'qty', 'side', 'price', 'reason', 'timestamp', 'transactionHash', 'additionalProperties']
-    additional_properties = data.get('additional_properties', {})
+    additional_properties = data.get('additional_properties') or {}
🧰 Tools
🪛 Ruff (0.15.5)

[warning] 31-31: Missing return type annotation for classmethod unwrap_additional_properties

(ANN206)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@sdk/async_api/spot_trade_bust.py` around lines 29 - 47, The pre-validator
unwrap_additional_properties assumes non-dict inputs implement model_dump and
that additional_properties is a dict; guard by first checking if data is a dict
and if not, only try to call data.model_dump() when hasattr(data, "model_dump"),
otherwise return data unchanged so scalars/None/lists bypass this unwrapping;
then ensure additional_properties = data.get('additional_properties') and if
it's None or not isinstance(additional_properties, dict) set it to {} before
merging unknown keys; also prefer Python "in" checks (e.g., if obj_key not in
known_json_properties) when iterating unknown_object_properties in
unwrap_additional_properties.


10 changes: 10 additions & 0 deletions sdk/async_api/wallet_spot_trade_bust_update_payload.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from __future__ import annotations
from typing import Any, List, Dict, Optional
from pydantic import BaseModel, Field
from sdk.async_api.channel_data_message_type import ChannelDataMessageType
from sdk.async_api.spot_trade_bust import SpotTradeBust
class WalletSpotTradeBustUpdatePayload(BaseModel):
type: ChannelDataMessageType = Field(description='''Message type for channel data updates''')
timestamp: float = Field(description='''Update timestamp (milliseconds)''')
channel: str = Field(description='''Channel pattern for wallet spot trade busts''')
data: List[SpotTradeBust] = Field()
Comment on lines +2 to +10
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick | 🔵 Trivial

Use built-in generics in this new payload model.

Ruff is already flagging UP035 here. With the repo's Python 3.12 baseline, list[SpotTradeBust] should replace List[SpotTradeBust] in new code.

♻️ Minimal cleanup
-from typing import Any, List, Dict, Optional
 from pydantic import BaseModel, Field
 from sdk.async_api.channel_data_message_type import ChannelDataMessageType
 from sdk.async_api.spot_trade_bust import SpotTradeBust
 class WalletSpotTradeBustUpdatePayload(BaseModel): 
   type: ChannelDataMessageType = Field(description='''Message type for channel data updates''')
   timestamp: float = Field(description='''Update timestamp (milliseconds)''')
   channel: str = Field(description='''Channel pattern for wallet spot trade busts''')
-  data: List[SpotTradeBust] = Field()
+  data: list[SpotTradeBust] = Field()

As per coding guidelines, "Require Python 3.12+ for runtime and Python 3.10 for type checking with strict mypy configuration".

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
from typing import Any, List, Dict, Optional
from pydantic import BaseModel, Field
from sdk.async_api.channel_data_message_type import ChannelDataMessageType
from sdk.async_api.spot_trade_bust import SpotTradeBust
class WalletSpotTradeBustUpdatePayload(BaseModel):
type: ChannelDataMessageType = Field(description='''Message type for channel data updates''')
timestamp: float = Field(description='''Update timestamp (milliseconds)''')
channel: str = Field(description='''Channel pattern for wallet spot trade busts''')
data: List[SpotTradeBust] = Field()
from typing import Any, Dict, Optional
from pydantic import BaseModel, Field
from sdk.async_api.channel_data_message_type import ChannelDataMessageType
from sdk.async_api.spot_trade_bust import SpotTradeBust
class WalletSpotTradeBustUpdatePayload(BaseModel):
type: ChannelDataMessageType = Field(description='''Message type for channel data updates''')
timestamp: float = Field(description='''Update timestamp (milliseconds)''')
channel: str = Field(description='''Channel pattern for wallet spot trade busts''')
data: list[SpotTradeBust] = Field()
🧰 Tools
🪛 Ruff (0.15.5)

[warning] 2-2: typing.List is deprecated, use list instead

(UP035)


[warning] 2-2: typing.Dict is deprecated, use dict instead

(UP035)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@sdk/async_api/wallet_spot_trade_bust_update_payload.py` around lines 2 - 10,
The payload model WalletSpotTradeBustUpdatePayload is using typing.List which
triggers UP035; change the data field to use the built-in generic
list[SpotTradeBust] instead of List[SpotTradeBust], update the import list to
remove List (keep Any, Dict, Optional only if used) and ensure the Field
declaration for data remains the same; this replaces the typing generic with
Python 3.12+ built-in generics while leaving the class name, type annotations
(type, timestamp, channel), and SpotTradeBust reference unchanged.

6 changes: 5 additions & 1 deletion sdk/open_api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)

The version of the OpenAPI document: 2.1.4
The version of the OpenAPI document: 2.1.5
Generated by OpenAPI Generator (https://openapi-generator.tech)

Do not edit the class manually.
Expand Down Expand Up @@ -68,6 +68,8 @@
"SpotExecution",
"SpotExecutionList",
"SpotMarketDefinition",
"SpotTradeBust",
"SpotTradeBustList",
"TierType",
"TimeInForce",
"WalletConfiguration",
Expand Down Expand Up @@ -128,6 +130,8 @@
from sdk.open_api.models.spot_execution import SpotExecution as SpotExecution
from sdk.open_api.models.spot_execution_list import SpotExecutionList as SpotExecutionList
from sdk.open_api.models.spot_market_definition import SpotMarketDefinition as SpotMarketDefinition
from sdk.open_api.models.spot_trade_bust import SpotTradeBust as SpotTradeBust
from sdk.open_api.models.spot_trade_bust_list import SpotTradeBustList as SpotTradeBustList
from sdk.open_api.models.tier_type import TierType as TierType
from sdk.open_api.models.time_in_force import TimeInForce as TimeInForce
from sdk.open_api.models.wallet_configuration import WalletConfiguration as WalletConfiguration
Loading
Loading