Skip to content

fix(core): use cls instead of self in PostMeltResponse.from_melt_quote#1007

Merged
a1denvalu3 merged 1 commit into
cashubtc:mainfrom
KvngMikey:melt_quote_cls_fix
May 15, 2026
Merged

fix(core): use cls instead of self in PostMeltResponse.from_melt_quote#1007
a1denvalu3 merged 1 commit into
cashubtc:mainfrom
KvngMikey:melt_quote_cls_fix

Conversation

@KvngMikey
Copy link
Copy Markdown
Contributor

@KvngMikey KvngMikey commented May 15, 2026

Fixes #1006

Summary

PostMeltQuoteResponse.from_melt_quote was decorated with @classmethod but had two bugs:

  • The first parameter was named self instead of cls, inconsistent with Python classmethod conventions.
  • The return statement hardcoded PostMeltQuoteResponse.model_validate(to_dict) instead of cls.model_validate(to_dict), silently returning a PostMeltQuoteResponse instance even when called on a subclass.

Changes

  • Renamed first parameter from self to cls
  • Replaced PostMeltQuoteResponse.model_validate(to_dict) with cls.model_validate(to_dict)

This now matches the existing pattern in PostMintQuoteResponse.from_mint_quote in cashu/core/models/mint_quote.py.

Copilot AI review requested due to automatic review settings May 15, 2026 11:39
@github-project-automation github-project-automation Bot moved this to Backlog in nutshell May 15, 2026
Copy link
Copy Markdown

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 PostMeltQuoteResponse.from_melt_quote so the classmethod uses cls, preserving subclass-friendly construction consistent with other model factory methods.

Changes:

  • Renames the classmethod receiver from self to cls.
  • Uses cls.model_validate(...) instead of hard-coding PostMeltQuoteResponse.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 15, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 75.35%. Comparing base (2cf3598) to head (3908d33).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1007      +/-   ##
==========================================
- Coverage   75.44%   75.35%   -0.10%     
==========================================
  Files         110      110              
  Lines       11798    11798              
==========================================
- Hits         8901     8890      -11     
- Misses       2897     2908      +11     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@a1denvalu3 a1denvalu3 merged commit ce07276 into cashubtc:main May 15, 2026
30 of 33 checks passed
@github-project-automation github-project-automation Bot moved this from Backlog to Done in nutshell May 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

fix: PostMeltQuoteResponse.from_melt_quote uses self instead of cls and hardcodes class in @classmethod

3 participants