Skip to content

Commit

Permalink
Merge branch 'master' into format-W0108
Browse files Browse the repository at this point in the history
  • Loading branch information
nasnoisaac committed Nov 13, 2021
2 parents 212a035 + bd6a6ed commit a9cacd5
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/presubmit.yml
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,W0108,R1705,R1732,C0200
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
3 changes: 2 additions & 1 deletion python/taichi/lang/ast/checkers.py
Expand Up @@ -55,7 +55,8 @@ def get_error_location(self, node):
lineno = self._func_lineno + node.lineno - 1
return f'file={self._func_file} kernel={self._func_name} line={lineno}'

def should_check(self, node):
@staticmethod
def should_check(node):
if not isinstance(node, ast.stmt):
return False
# TODO(#536): Frontend pass should help make sure |func| is a valid AST for
Expand Down
1 change: 1 addition & 0 deletions python/taichi/lang/common_ops.py
Expand Up @@ -288,6 +288,7 @@ def assign(self, other):
_taichi_skip_traceback = 1
return ti.assign(self, other)

# pylint: disable=R0201
def augassign(self, x, op):
"""Generate the computing expression between self and the given operand of given operator and assigned to self.
Expand Down
18 changes: 12 additions & 6 deletions python/taichi/lang/impl.py
Expand Up @@ -301,7 +301,8 @@ def create_program(self):
if self.prog is None:
self.prog = _ti_core.Program()

def materialize_root_fb(self, is_first_call):
@staticmethod
def materialize_root_fb(is_first_call):
if root.finalized:
return
if not is_first_call and root.empty:
Expand All @@ -315,7 +316,8 @@ def materialize_root_fb(self, is_first_call):
global _root_fb
_root_fb = FieldsBuilder()

def _finalize_root_fb_for_aot(self):
@staticmethod
def _finalize_root_fb_for_aot():
if _root_fb.finalized:
raise RuntimeError(
'AOT: can only finalize the root FieldsBuilder once')
Expand Down Expand Up @@ -483,20 +485,24 @@ def __getattr__(self, item):

class _Root:
"""Wrapper around the default root FieldsBuilder instance."""
def parent(self, n=1):
@staticmethod
def parent(n=1):
"""Same as :func:`taichi.SNode.parent`"""
return _root_fb.root.parent(n)

def loop_range(self):
@staticmethod
def loop_range():
"""Same as :func:`taichi.SNode.loop_range`"""
return _root_fb.root.loop_range()

def get_children(self):
@staticmethod
def get_children():
"""Same as :func:`taichi.SNode.get_children`"""
return _root_fb.root.get_children()

# TODO: Record all of the SNodeTrees that finalized under 'ti.root'
def deactivate_all(self):
@staticmethod
def deactivate_all():
warning(
"""'ti.root.deactivate_all()' would deactivate all finalized snodes."""
)
Expand Down
3 changes: 2 additions & 1 deletion python/taichi/lang/kernel_impl.py
Expand Up @@ -740,7 +740,8 @@ def call_back():

return func__

def match_ext_arr(self, v):
@staticmethod
def match_ext_arr(v):
has_array = isinstance(v, np.ndarray)
if not has_array and util.has_pytorch():
has_array = isinstance(v, torch.Tensor)
Expand Down
18 changes: 12 additions & 6 deletions python/taichi/main.py
Expand Up @@ -88,7 +88,8 @@ def __call__(self):

return getattr(self, args.command)(sys.argv[2:])

def _get_friend_links(self):
@staticmethod
def _get_friend_links():
return '\n' \
'Docs: https://docs.taichi.graphics/\n' \
'GitHub: https://github.com/taichi-dev/taichi/\n' \
Expand Down Expand Up @@ -211,15 +212,17 @@ def example(self, arguments: list = sys.argv[2:]):

runpy.run_path(target, run_name='__main__')

@staticmethod
@register
def changelog(self, arguments: list = sys.argv[2:]):
def changelog(arguments: list = sys.argv[2:]):
"""Display changelog of current version"""
changelog_md = os.path.join(ti.package_root(), 'CHANGELOG.md')
with open(changelog_md) as f:
print(f.read())

@staticmethod
@register
def release(self, arguments: list = sys.argv[2:]):
def release(arguments: list = sys.argv[2:]):
"""Make source code release"""
raise RuntimeError('TBD')

Expand Down Expand Up @@ -417,18 +420,21 @@ def video(self, arguments: list = sys.argv[2:]):
frame_rate=args.framerate)
ti.info(f'Done! Output video file = {args.output_file}')

@staticmethod
@register
def doc(self, arguments: list = sys.argv[2:]):
def doc(arguments: list = sys.argv[2:]):
"""Build documentation"""
raise RuntimeError('TBD')

@staticmethod
@register
def format(self, arguments: list = sys.argv[2:]):
def format(arguments: list = sys.argv[2:]):
"""Reformat modified source files"""
raise RuntimeError('Please run python misc/code_format.py instead')

@staticmethod
@register
def format_all(self, arguments: list = sys.argv[2:]):
def format_all(arguments: list = sys.argv[2:]):
"""Reformat all source files"""
raise RuntimeError('Please run python misc/code_format.py instead')

Expand Down
3 changes: 2 additions & 1 deletion python/taichi/misc/gui.py
Expand Up @@ -127,7 +127,8 @@ def value(self):
def value(self, value):
self.gui.core.set_widget_value(self.wid, value)

def get_bool_environ(self, key, default):
@staticmethod
def get_bool_environ(key, default):
"""Get an environment variable and cast to bool.
Args:
key (str): The environment variable key.
Expand Down
3 changes: 2 additions & 1 deletion python/taichi/profiler/kernelprofiler.py
Expand Up @@ -202,7 +202,8 @@ def _count_statistics(self):
reverse=True)
}

def _make_table_header(self, mode):
@staticmethod
def _make_table_header(mode):
header_str = f'Kernel Profiler({mode})'
arch_name = f' @ {_ti_core.arch_name(ti.cfg.arch).upper()}'
device_name = impl.get_runtime().prog.get_kernel_profiler_device_name()
Expand Down

0 comments on commit a9cacd5

Please sign in to comment.