mypy
mypy copied to clipboard
Refactor: simplify combine_function_signatures by reducing line count and preserving comments
This pull request contributes to issue #5917, which encourages the decomposition and simplification of overly long methods to improve code clarity and maintainability.
Summary of changes
Refactored the combine_function_signatures method to reduce line count and eliminate redundancy, while preserving all original logic and explanatory comments.
Key improvements:
- Reduced vertical space and simplified control flow
- Preserved all original comments, including the TODO
- Kept behavior unchanged and all test cases passing
Notes
- This is a pure refactor in line with issue #5917.
- The logic has not been modified, only cleaned up for readability and maintainability.
Diff from mypy_primer, showing the effect of this PR on open source code:
pyp (https://github.com/hauntsaninja/pyp): 1.50x faster (19.0s -> 12.7s in single noisy sample)
nox (https://github.com/wntrblm/nox): 1.28x slower (27.5s -> 35.2s in single noisy sample)
typeshed-stats (https://github.com/AlexWaygood/typeshed-stats): 1.56x slower (61.2s -> 95.2s in single noisy sample)
discord.py (https://github.com/Rapptz/discord.py): 1.07x slower (264.1s -> 281.4s in single noisy sample)
Diff from mypy_primer, showing the effect of this PR on open source code:
nox (https://github.com/wntrblm/nox): 1.31x slower (30.9s -> 40.5s in single noisy sample)
typeshed-stats (https://github.com/AlexWaygood/typeshed-stats): 1.55x slower (66.3s -> 102.5s in single noisy sample)
materialize (https://github.com/MaterializeInc/materialize): 1.06x slower (135.9s -> 144.5s in single noisy sample)
imagehash (https://github.com/JohannesBuchner/imagehash): 1.06x slower (74.0s -> 78.8s in single noisy sample)
discord.py (https://github.com/Rapptz/discord.py): 1.10x slower (281.1s -> 308.0s in single noisy sample)