Beispiel #1
0
    """ does nothing """


def bad_unpacking():
    """ one return isn't unpackable """
    if True:
        return None
    return [1, 2]


a, b = NonSeq()  # [unpacking-non-sequence]
a, b = ValueError  # [unpacking-non-sequence]
a, b = None  # [unpacking-non-sequence]
a, b = 1  # [unpacking-non-sequence]
a, b = nonseq  # [unpacking-non-sequence]
a, b = nonseq()  # [unpacking-non-sequence]
a, b = bad_unpacking()  # [unpacking-non-sequence]
a, b = nonseq_func  # [unpacking-non-sequence]


class ClassUnpacking(object):
    """ Check unpacking as instance attributes. """
    def test(self):
        """ test unpacking in instance attributes. """

        self.a, self.b = 1, 2
        self.a, self.b = {1: 2, 2: 3}
        self.a, self.b = "xy"
        self.a, c = "xy"
        c, self.a = good_unpacking()
        self.a, self.b = Iter()
    """ does nothing """


def bad_unpacking():
    """ one return isn't unpackable """
    if True:
        return None
    return [1, 2]


a, b = NonSeq()  # [unpacking-non-sequence]
a, b = ValueError  # [unpacking-non-sequence]
a, b = None  # [unpacking-non-sequence]
a, b = 1  # [unpacking-non-sequence]
a, b = nonseq  # [unpacking-non-sequence]
a, b = nonseq()  # [unpacking-non-sequence]
a, b = bad_unpacking()  # [unpacking-non-sequence]
a, b = nonseq_func  # [unpacking-non-sequence]


class ClassUnpacking(object):
    """ Check unpacking as instance attributes. """

    def test(self):
        """ test unpacking in instance attributes. """

        self.a, self.b = 1, 2
        self.a, self.b = {1: 2, 2: 3}
        self.a, self.b = "xy"
        self.a, c = "xy"
        c, self.a = good_unpacking()