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

Do not convert `== True/False` to `is`. #79

Closed DRMacIver closed 1 year ago

DRMacIver commented 1 year ago

Fixes #74.

This updates shed --refactor so that equality comparisons with True or False are no longer converted to is under an circumstances, as it is a fundamentally semantics changing refactor.

In particular the strongest prompting example is that 1.0 == True is true, but 1.0 is True is false.

This change leaves the logic for converting x == None to x is None in place, as although this can in principle change semantics, it should not for an well-behaved equalit implementation, and I'm not aware of any examples in the wild of equality being badly behaved in this particular way.