asottile / pyupgrade

A tool (and pre-commit hook) to automatically upgrade syntax for newer versions of the language.
MIT License
3.5k stars 177 forks source link

`python-no-eval` invalid for pytorch models #952

Closed Mahdi-Hosseinali closed 2 months ago

Mahdi-Hosseinali commented 2 months ago

Hi, Thanks for the great work. This package has improved the quality of the legacy code I'm working with dramatically. I have a issue with a new project I'm working on. Pytorch ml models can have different behaviors during training and inference. When the training is done, they should be put in evaluation mode. pyupgrade complains about python-no-eval. When the only pre-commit issue is the no-eval, I use--no-verify` flag but I have to do this every time I make some changes to that file. I am not sure what is the best way to approach this.

asottile commented 2 months ago

pyupgrade doesn't do anything with eval or complain it just changes code

asottile commented 2 months ago

your princess is in another castle