Zac-HD / shed

`shed` canonicalises Python code. Shed your legacy, stop bikeshedding, and move on. Black++
https://pypi.org/project/shed/
GNU Affero General Public License v3.0
343 stars 23 forks source link

Stop shed from refactoring certain lines? #73

Closed salimfadhley closed 1 year ago

salimfadhley commented 1 year ago

Shed's refactor option sometimes gets it wrong.

It would be great if it were possible to selectively tell shed not to refactor certain lines of code, for example by placing a comment.

The mechanism could be consistent with how mypy works - a comment at the top of the file would tell shed not to refactor anything in that file. A comment at the top of a function would prevent that function from being refactored. A comment anywhere else would prevent that line from being refactored.

Zac-HD commented 1 year ago

This sounds pretty tricky to implement for all the different refactoring rules, so I'd prefer to fix shed when it gets something wrong instead.

(although note also that this is a side project to my main OSS volunteering, so no guarantees of timely fixes unless someone else volunteers to write them)

salimfadhley commented 1 year ago

Hi @Zac-HD,

The thing that Shed gets wrong for me is sqlalchemycriteria: These are often expressed as:

objectname.columname == True

Which shed will refactor as:

objectnae.columname is True

Which doesn't have quite the same meaning, and will break SQLAlchemy. I've had to switch off refactor to prevent this from breaking.

Zac-HD commented 1 year ago

I've opened an issue to make sure that this doesn't get forgotten before someone volunteers to fix it 🙂