Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Lang] Fix pylint rule W0108 #3482

Merged
merged 9 commits into from
Nov 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/presubmit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ jobs:
exit 0
fi
# Make sure pylint doesn't regress
pylint python/taichi/ --disable=all --enable=C0121,C0415,W0401,W0611,W0202,R0205,R0402,R1703,R1705,R1732,C0200,R0201
pylint python/taichi/ --disable=all --enable=C0121,C0415,W0401,W0611,W0202,R0205,R0402,R1703,R1705,R1732,C0200,R0201,W0108
if [ $? -eq 0 ]
then
echo "PASSED: pylint is happy"
Expand Down
8 changes: 4 additions & 4 deletions python/taichi/lang/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@

When this is used, Taichi automatically picks the matching CPU backend.
"""
timeline_clear = lambda: impl.get_runtime().prog.timeline_clear()
timeline_save = lambda fn: impl.get_runtime().prog.timeline_save(fn)
timeline_clear = lambda: impl.get_runtime().prog.timeline_clear() # pylint: disable=unnecessary-lambda
timeline_save = lambda fn: impl.get_runtime().prog.timeline_save(fn) # pylint: disable=unnecessary-lambda

# Legacy API
type_factory_ = _ti_core.get_type_factory_instance()
Expand Down Expand Up @@ -989,7 +989,7 @@ def is_arch_supported(arch):
metal: _ti_core.with_metal,
opengl: _ti_core.with_opengl,
cc: _ti_core.with_cc,
vulkan: lambda: _ti_core.with_vulkan(),
vulkan: _ti_core.with_vulkan,
wasm: lambda: True,
cpu: lambda: True,
}
Expand All @@ -1012,7 +1012,7 @@ def supported_archs():
List[taichi_core.Arch]: All supported archs on the machine.
"""
archs = set([cpu, cuda, metal, vulkan, opengl, cc])
archs = set(filter(lambda x: is_arch_supported(x), archs))
archs = set(filter(is_arch_supported, archs))

wanted_archs = os.environ.get('TI_WANTED_ARCHS', '')
want_exclude = wanted_archs.startswith('^')
Expand Down
6 changes: 3 additions & 3 deletions python/taichi/lang/ir_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ def build_UnaryOp(ctx, node):
op = {
ast.UAdd: lambda l: l,
ast.USub: lambda l: -l,
ast.Not: lambda l: ti.logical_not(l),
ast.Not: ti.logical_not,
ast.Invert: lambda l: ~l,
}.get(type(node.op))
node.ptr = op(node.operand.ptr)
Expand All @@ -473,8 +473,8 @@ def build_UnaryOp(ctx, node):
def build_BoolOp(ctx, node):
node.values = build_stmts(ctx, node.values)
op = {
ast.And: lambda l, r: ti.logical_and(l, r),
ast.Or: lambda l, r: ti.logical_or(l, r),
ast.And: ti.logical_and,
ast.Or: ti.logical_or,
}.get(type(node.op))
result = op(node.values[0].ptr, node.values[1].ptr)
for i in range(2, len(node.values)):
Expand Down