mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-25 14:45:12 +00:00
Fix new flake8 E741 error from using l
variable
The just-updated flake8 package hits a bunch of: E741 ambiguous variable name 'l' warnings. This commit renames them all from `l` to `lst` (they are all list values) to avoid the error.
This commit is contained in:
parent
32ef69acde
commit
5c7a290d37
@ -4,21 +4,21 @@ from pybind11_tests import ConstructorStats, UserType
|
|||||||
|
|
||||||
|
|
||||||
def test_string_list():
|
def test_string_list():
|
||||||
l = m.StringList()
|
lst = m.StringList()
|
||||||
l.push_back("Element 1")
|
lst.push_back("Element 1")
|
||||||
l.push_back("Element 2")
|
lst.push_back("Element 2")
|
||||||
assert m.print_opaque_list(l) == "Opaque list: [Element 1, Element 2]"
|
assert m.print_opaque_list(lst) == "Opaque list: [Element 1, Element 2]"
|
||||||
assert l.back() == "Element 2"
|
assert lst.back() == "Element 2"
|
||||||
|
|
||||||
for i, k in enumerate(l, start=1):
|
for i, k in enumerate(lst, start=1):
|
||||||
assert k == "Element {}".format(i)
|
assert k == "Element {}".format(i)
|
||||||
l.pop_back()
|
lst.pop_back()
|
||||||
assert m.print_opaque_list(l) == "Opaque list: [Element 1]"
|
assert m.print_opaque_list(lst) == "Opaque list: [Element 1]"
|
||||||
|
|
||||||
cvp = m.ClassWithSTLVecProperty()
|
cvp = m.ClassWithSTLVecProperty()
|
||||||
assert m.print_opaque_list(cvp.stringList) == "Opaque list: []"
|
assert m.print_opaque_list(cvp.stringList) == "Opaque list: []"
|
||||||
|
|
||||||
cvp.stringList = l
|
cvp.stringList = lst
|
||||||
cvp.stringList.push_back("Element 3")
|
cvp.stringList.push_back("Element 3")
|
||||||
assert m.print_opaque_list(cvp.stringList) == "Opaque list: [Element 1, Element 3]"
|
assert m.print_opaque_list(cvp.stringList) == "Opaque list: [Element 1, Element 3]"
|
||||||
|
|
||||||
|
@ -7,11 +7,11 @@ from pybind11_tests import debug_enabled
|
|||||||
|
|
||||||
def test_list(capture, doc):
|
def test_list(capture, doc):
|
||||||
with capture:
|
with capture:
|
||||||
l = m.get_list()
|
lst = m.get_list()
|
||||||
assert l == ["overwritten"]
|
assert lst == ["overwritten"]
|
||||||
|
|
||||||
l.append("value2")
|
lst.append("value2")
|
||||||
m.print_list(l)
|
m.print_list(lst)
|
||||||
assert capture.unordered == """
|
assert capture.unordered == """
|
||||||
Entry at position 0: value
|
Entry at position 0: value
|
||||||
list item 0: overwritten
|
list item 0: overwritten
|
||||||
|
@ -131,9 +131,9 @@ def test_python_iterator_in_cpp():
|
|||||||
m.iterator_to_list(iter(bad_next_call, None))
|
m.iterator_to_list(iter(bad_next_call, None))
|
||||||
assert str(excinfo.value) == "py::iterator::advance() should propagate errors"
|
assert str(excinfo.value) == "py::iterator::advance() should propagate errors"
|
||||||
|
|
||||||
l = [1, None, 0, None]
|
lst = [1, None, 0, None]
|
||||||
assert m.count_none(l) == 2
|
assert m.count_none(lst) == 2
|
||||||
assert m.find_none(l) is True
|
assert m.find_none(lst) is True
|
||||||
assert m.count_nonzeros({"a": 0, "b": 1, "c": 2}) == 2
|
assert m.count_nonzeros({"a": 0, "b": 1, "c": 2}) == 2
|
||||||
|
|
||||||
r = range(5)
|
r = range(5)
|
||||||
|
@ -6,11 +6,11 @@ from pybind11_tests import UserType
|
|||||||
|
|
||||||
def test_vector(doc):
|
def test_vector(doc):
|
||||||
"""std::vector <-> list"""
|
"""std::vector <-> list"""
|
||||||
l = m.cast_vector()
|
lst = m.cast_vector()
|
||||||
assert l == [1]
|
assert lst == [1]
|
||||||
l.append(2)
|
lst.append(2)
|
||||||
assert m.load_vector(l)
|
assert m.load_vector(lst)
|
||||||
assert m.load_vector(tuple(l))
|
assert m.load_vector(tuple(lst))
|
||||||
|
|
||||||
assert m.cast_bool_vector() == [True, False]
|
assert m.cast_bool_vector() == [True, False]
|
||||||
assert m.load_bool_vector([True, False])
|
assert m.load_bool_vector([True, False])
|
||||||
@ -24,9 +24,9 @@ def test_vector(doc):
|
|||||||
|
|
||||||
def test_array(doc):
|
def test_array(doc):
|
||||||
"""std::array <-> list"""
|
"""std::array <-> list"""
|
||||||
l = m.cast_array()
|
lst = m.cast_array()
|
||||||
assert l == [1, 2]
|
assert lst == [1, 2]
|
||||||
assert m.load_array(l)
|
assert m.load_array(lst)
|
||||||
|
|
||||||
assert doc(m.cast_array) == "cast_array() -> List[int[2]]"
|
assert doc(m.cast_array) == "cast_array() -> List[int[2]]"
|
||||||
assert doc(m.load_array) == "load_array(arg0: List[int[2]]) -> bool"
|
assert doc(m.load_array) == "load_array(arg0: List[int[2]]) -> bool"
|
||||||
@ -34,9 +34,9 @@ def test_array(doc):
|
|||||||
|
|
||||||
def test_valarray(doc):
|
def test_valarray(doc):
|
||||||
"""std::valarray <-> list"""
|
"""std::valarray <-> list"""
|
||||||
l = m.cast_valarray()
|
lst = m.cast_valarray()
|
||||||
assert l == [1, 4, 9]
|
assert lst == [1, 4, 9]
|
||||||
assert m.load_valarray(l)
|
assert m.load_valarray(lst)
|
||||||
|
|
||||||
assert doc(m.cast_valarray) == "cast_valarray() -> List[int]"
|
assert doc(m.cast_valarray) == "cast_valarray() -> List[int]"
|
||||||
assert doc(m.load_valarray) == "load_valarray(arg0: List[int]) -> bool"
|
assert doc(m.load_valarray) == "load_valarray(arg0: List[int]) -> bool"
|
||||||
|
Loading…
Reference in New Issue
Block a user