sourcery-ai / sourcery

Instant AI code reviews
https://sourcery.ai
MIT License
1.53k stars 66 forks source link

`square-identity` could be reworked for an indeterminate amount of exponents #249

Open diceroll123 opened 2 years ago

diceroll123 commented 2 years ago

Issue description or question

For the code given,

def cube(t: float) -> float:
    return t * t * t 

The suggested replacement ends up being

def cube(t: float) -> float:
    return t**2 * t

This could probably somewhat easily be scaled to work for any amount of exponents to get return t**3 for this case, I'd assume!

Sourcery Version

v0.12.1

Code editor or IDE name and version

Version: 1.68.1 (Universal) Commit: 30d9c6cd9483b2cc586687151bcbcd635f373630 Date: 2022-06-14T12:52:13.188Z Electron: 17.4.7 Chromium: 98.0.4758.141 Node.js: 16.13.0 V8: 9.8.177.13-electron.0 OS: Darwin x64 21.6.0

reka commented 2 years ago

Hi @diceroll123 ,

Thanks a lot, that's an excellent point. :+1: We'll look into it and see whether and how we can make the square-identity refactoring more flexible.