Skip to content

Fix #895: replace magic number in broker param_count check#1209

Open
Chessing234 wants to merge 1 commit intomarketcalls:mainfrom
Chessing234:fix/issue-895
Open

Fix #895: replace magic number in broker param_count check#1209
Chessing234 wants to merge 1 commit intomarketcalls:mainfrom
Chessing234:fix/issue-895

Conversation

@Chessing234
Copy link
Copy Markdown
Contributor

@Chessing234 Chessing234 commented Apr 4, 2026

Summary

  • Defined named constants _MIN_BROKER_INIT_PARAMS = 2 and _MIN_BROKER_INIT_PARAMS_WITH_FEED = 3 to replace unexplained magic numbers
  • Applied across quotes_service.py, history_service.py, and depth_service.py
  • The constants clarify that 2 = self + auth_token, and 3 adds feed_token

Closes #895

Verification

  • All modified files pass Python syntax validation
  • No behavioral changes — only readability improvement
  • Constants are module-level with explanatory comments

Test plan

  • Application starts normally
  • Broker data handlers initialize correctly (quotes, history, depth)
  • No regressions in broker API calls

🤖 Generated with Claude Code


Summary by cubic

Replace magic numbers in BrokerData.__init__ param-count checks with named constants for clearer intent; no behavior change. Fixes #895.

  • Refactors
    • Added _MIN_BROKER_INIT_PARAMS = 2 (self + auth_token) in quotes_service.py and history_service.py.
    • In depth_service.py, also added _MIN_BROKER_INIT_PARAMS_WITH_FEED = 3 (adds feed_token).
    • Updated conditional checks to use these constants when creating BrokerData (auth only, auth+feed, auth+feed+user_id).
    • Added brief comments explaining the parameter mapping.

Written for commit 347aefa. Summary will update on new commits.

…check

Define named constants _MIN_BROKER_INIT_PARAMS (2) and
_MIN_BROKER_INIT_PARAMS_WITH_FEED (3) to replace unexplained magic
numbers in BrokerData initialization across quotes_service,
history_service, and depth_service. The constants clarify that 2
represents self + auth_token and 3 adds feed_token.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

No issues found across 3 files

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.

python: Replace magic number in broker init param_count check with named constant

1 participant