Skip to content

Refactored converter.py to handle convert logic only #455

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 12, 2025

Conversation

sue-lim
Copy link
Contributor

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

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
Copy link
Contributor Author

sue-lim commented Jun 12, 2025

@DhanushNehru - please kindly approve :)

@DhanushNehru DhanushNehru merged commit c5ccc03 into DhanushNehru: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