from typing import List
class Foo():
def __init__(self, _a : int, _b : bool):
self.a = _a
self.b = _b
class Bar(List[Foo]):
def print(self):
for entry in self: # Non-iterable value self is used in an iterating contextpylint(not-an-iterable)
print(entry.a)
print(entry.b)
foo0 = Foo(0, True)
foo1 = Foo(1, False)
foo2 = Foo(2, True)
foo3 = Foo(3, False)
bar = Bar()
bar.append(foo0) # Instance of 'Bar' has no 'append' memberpylint(no-member)
bar.append(foo1) # Instance of 'Bar' has no 'append' memberpylint(no-member)
bar.append(foo2) # Instance of 'Bar' has no 'append' memberpylint(no-member)
bar.append(foo3) # Instance of 'Bar' has no 'append' memberpylint(no-member)
bar.print()
它运行得很好,似乎可以完成预期的工作,但Pylint似乎并不喜欢它(注释中的错误消息。)>有没有办法使此停止?
我编写了以下代码:输入import List类Foo():def __init __(self,_a:int,_b:bool):self.a = _a self.b = _b class Bar(List [Foo] ):def打印(...
from typing import List
class Foo():
def __init__(self, _a : int, _b : bool):
self.a = _a
self.b = _b
class Bar(List[Foo]):
def print(self):
for entry in list(self):
print(entry.a)
print(entry.b)
foo0 = Foo(0, True)
foo1 = Foo(1, False)
foo2 = Foo(2, True)
foo3 = Foo(3, False)
bar = Bar([foo0,foo1,foo2,foo3])
bar.print()