Skip to content

Conversation

parth-soni07
Copy link

Overview?

This pull request refactors multiple modules in the codebase to eliminate the use of magic numbers and hardcoded values. Instead, all such values are now defined as named constants or enums. This change is aimed at improving code clarity, maintainability, and adherence to best practices.

Details

What was changed?

  • Named Constants

    • Introduced descriptive named constants for configuration defaults, timeouts, protocol parameters, and other previously hardcoded values.
    • Constants are now defined at the top of relevant files or in configuration sections, making them easy to locate and update.
  • Enums

    • Where appropriate (e.g., status codes), replaced repeated numeric values with Python Enum or IntEnum classes for better type safety and readability.
  • Code update

    • Replaced all direct usages of magic numbers in logic, class attributes, and function calls with the new named constants or enums.
    • Updated docstrings and inline comments to reference the new constants where relevant.

Impact

  • No functional changes:
    This is a non-breaking, internal refactor. All existing functionality remains unchanged.
  • Testing:
    All existing tests should continue to pass. No new tests are required, but this refactor lays the groundwork for easier future testing and configuration changes.

@parth-soni07 parth-soni07 changed the title Refactor/constants magic numbers Refactor: Replace magic numbers with named constants and enums for clarity and maintainability Sep 8, 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.

1 participant