pyupgrade
pyupgrade copied to clipboard
constant fold isinstance(x, (str, str))
input
import ham, value
import six
if isinstance(value, (six.text_type, str)):
ham()
actual output (with pyupgrade --py38-plus)
import ham, value
import six
if isinstance(value, (str, str)):
ham()
expected output:
import ham, value
import six
if isinstance(value, str):
ham()
Something similar is done for OSError aliases so perhaps that code can be adapted for this issue too. https://github.com/asottile/pyupgrade/blob/53c94718aae4074edde7099996c81ab7cc081ce3/pyupgrade/_plugins/oserror_aliases.py#L43
I'm going to make this work for the tuple case -- the union case is a little more complicated and I'll just leave that notimplemented