Skip to content

Refactored codebase for improved clarity and readability#2

Open
Georges-Procurified wants to merge 5 commits intohttpie:mainfrom
Georges-Procurified:georges-dev
Open

Refactored codebase for improved clarity and readability#2
Georges-Procurified wants to merge 5 commits intohttpie:mainfrom
Georges-Procurified:georges-dev

Conversation

@Georges-Procurified
Copy link

@Georges-Procurified Georges-Procurified commented Oct 16, 2024

Hello! I want to start by saying I love this project—it's been incredibly useful to me! I would love to contribute by performing some refactoring and cleanup to make the code more intuitive and self-documenting.

Here’s a summary of the changes I made:

  • Renamed variables and function parameters to more descriptive alternatives.
  • Split up larger helper functions into smaller, more manageable ones, and updated their names for clarity.
  • Moved utility and helper functions from fractional_indexing.py into separate modules for better organization.
  • Updated the test file to align with the new import paths and renamed exceptions.

All changes were tested locally, and I'm happy to report that 100% of the tests passed, maintaining the original functionality.

I’d love to know how I can contribute these changes back to the project. Could you guide me through the process?

Looking forward to your response!

Best regards,
Georges

Reordered the functions to follow a chronological order
Refactor and improve code readability for order key generation

- Improved function and variable naming for clarity (e.g., renamed `a`, `b`, `x`, `i` to `start_key`, `end_key`, `integer_str`, `integer_length`).
- Added comprehensive and consistent docstrings to all functions, providing better explanations for inputs, outputs, and behavior.
- Refactored `midpoint` logic to simplify complex calculations, improving readability and modularity.
- Broke down parts of `increment_integer` and `decrement_integer` into clearer steps.
- Applied input validation for functions to ensure robustness and better error handling (e.g., added checks in `generate_key_between`).
- Simplified redundant checks for `None` values across multiple functions by consolidating logic.
- Enhanced error messages in `OrderKeyError` for better debugging clarity.
- Applied type hints consistently across all functions.
- Added type hints across all functions
- renamed parameter n to number_of_keys
- renamed function midpoint to find_middle_key
- moved helper functions out of main fractional_indexing.py
- updated tests.py with new imports and error name
- moved handlers to main due to circular imports
- adjusted imports to be local, not relative
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant