Skip to content

Refactored converter.py to handle convert logic only - #455

Merged
DhanushNehru merged 3 commits into
wasmerio:mainfrom
sue-lim:UPDATE_CONVERTER.PY
Jun 12, 2025
Merged

Refactored converter.py to handle convert logic only#455
DhanushNehru merged 3 commits into
wasmerio:mainfrom
sue-lim:UPDATE_CONVERTER.PY

Conversation

@sue-lim

@sue-lim sue-lim commented Jun 12, 2025

Copy link
Copy Markdown
Contributor

Refactored converter.py to handle convert logic only

[FEATURE] Currency Script | Implement currency conversion logic in dedicated module #430

Summary

Refactored converter.py to streamline currency conversion logic using the CurrencyConverter class with a clearer structure and docstrings.

Description

This PR refactors the converter.py module to improve modularity, readability, and consistency. The changes focus on encapsulating currency conversion logic in a clean, testable way. Key updates include:

  • Created a clean and minimal CurrencyConverter class.
  • Simplified the convert() method using base currency (EUR) logic.
  • Added input validation for currency codes.
  • Included a manual test in the main block for direct debugging.
  • Updated docstrings with compact, beginner-friendly versions.
  • Ensured consistency with the structure used in currencies.py.

The changes are as follows:

  • Refactored logic into CurrencyConverter class.
  • Added basic error handling for invalid currency codes.
  • Reduced redundancy, improved structure.
  • Included inline docstrings and top-level module docstring.
  • Manual test block under if name == "main" included for quick verification.

Checks

in the repository

  • Made no changes that degrades the functioning of the repository
  • Gave each commit a better title (unlike updated README.md)

in the PR

  • Followed the format of the pull_request_template
  • Made the Pull Request in a small level (for the creator's wellfare)
  • Tested the changes you made, manually & via unittest

image

Thank You,

Sue

@sue-lim

sue-lim commented Jun 12, 2025

Copy link
Copy Markdown
Contributor Author

@DhanushNehru - please kindly approve :)

@DhanushNehru
DhanushNehru merged commit c5ccc03 into wasmerio:main Jun 12, 2025
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