Skip to content

Conversation

@rian-dolphin
Copy link

@rian-dolphin rian-dolphin commented Oct 9, 2025

Overview

Fixes incorrect enum inheritance - OrderType and AssetType inherited from enumerate (built-in function) instead of Enum class. Caused type checker errors and broken enum functionality. I noticed this after it was flagged by my type checker when building something downstream.

Changes

  1. Added from enum import Enum to py_clob_client/clob_types.py
  2. OrderType(enumerate):OrderType(str, Enum): (line 13)
  3. AssetType(enumerate):AssetType(str, Enum): (line 181)
  4. helpers.py:147 now uses .value for URL query params

Technical

enumerate is a function, not a class. Multiple inheritance from str and Enum provides:

  • Proper type checking/IDE support
  • Auto JSON serialization
  • Natural string operations
  • Full backward compatibility

URL builder needed update: __str__() on proper Enum returns "AssetType.COLLATERAL" not "COLLATERAL". Now use .value to extract string.

Note: StrEnum exists (Python 3.11+) but str, Enum ensures older version support.

Testing

pytest -s or make test - all 82 tests pass locally

Type

Bug fix/behavior correction

Status

  • Prefix PR title with [WIP] if necessary (changes not yet made).
  • Add tests to cover changes as needed. (NA)
  • Update documentation/changelog as needed. (NA)
  • Verify all tests run correctly in CI and pass. (Tests all passing locally)
  • Ready for review/merge.

@rian-dolphin rian-dolphin requested a review from a team as a code owner October 9, 2025 14:24
Copilot AI review requested due to automatic review settings October 9, 2025 14:24
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes incorrect enum inheritance where OrderType and AssetType were inheriting from the built-in enumerate function instead of the Enum class, causing type checker errors and broken enum functionality.

Key changes:

  • Added proper from enum import Enum import
  • Changed enum class inheritance to (str, Enum) for both OrderType and AssetType
  • Updated URL parameter building to use .value instead of __str__() method

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
py_clob_client/clob_types.py Added Enum import and fixed inheritance for OrderType and AssetType classes
py_clob_client/http_helpers/helpers.py Updated URL parameter building to use .value for proper enum string extraction

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@rian-dolphin
Copy link
Author

@poly-rodr any chance of a review? It's causing errors in type checkers.

@Mattwmaster58
Copy link

This is pretty annoying for code you want to be type checked, this throws a wrench in everything.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants