Get suggestions for refactoring and improving code structure.
{{language}}Programming language
Example: JavaScript
{{improvement_goals}}What to improve
Example: - Readability - Performance - Maintainability
{{code}}Code to refactor
Example: function processData(data) { ... }
{{constraints}}Any constraints
Example: Keep backward compatibility
Refactor this Python code to remove duplication and add type hints while maintaining Python 3.8+ compatibility.