Skip to content

Commit

Permalink
[Bug] [error] Add argument 'module' to 'warn_explicit' to show the de…
Browse files Browse the repository at this point in the history
…precated warning (#6467)

Issue: fixes #6423 

### Brief Summary

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
lin-hitonami and pre-commit-ci[bot] authored Oct 28, 2022
1 parent b347a21 commit 7cab180
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions python/taichi/lang/ast/ast_transformer.py
Original file line number Diff line number Diff line change
Expand Up @@ -426,8 +426,11 @@ def build_call_if_is_builtin(ctx, node, args, keywords):
name = "min" if func is min else "max"
warnings.warn_explicit(
f'Calling builtin function "{name}" in Taichi scope is deprecated. '
f'Please use "ti.{name}" instead.', DeprecationWarning,
ctx.file, node.lineno + ctx.lineno_offset)
f'Please use "ti.{name}" instead.',
DeprecationWarning,
ctx.file,
node.lineno + ctx.lineno_offset,
module="taichi")
return True
return False

Expand Down Expand Up @@ -471,8 +474,11 @@ def warn_if_is_external_func(ctx, node):
f'Calling non-taichi function "{name}". '
f'Scope inside the function is not processed by the Taichi AST transformer. '
f'The function may not work as expected. Proceed with caution! '
f'Maybe you can consider turning it into a @ti.func?', UserWarning,
ctx.file, node.lineno + ctx.lineno_offset)
f'Maybe you can consider turning it into a @ti.func?',
UserWarning,
ctx.file,
node.lineno + ctx.lineno_offset,
module="taichi")

@staticmethod
def build_Call(ctx, node):
Expand Down Expand Up @@ -902,8 +908,10 @@ def build_Compare(ctx, node):
name = "is" if isinstance(node_op, ast.Is) else "is not"
warnings.warn_explicit(
f'Operator "{name}" in Taichi scope is deprecated. Please avoid using it.',
DeprecationWarning, ctx.file,
node.lineno + ctx.lineno_offset)
DeprecationWarning,
ctx.file,
node.lineno + ctx.lineno_offset,
module="taichi")
if op is None:
if type(node_op) in ops_static:
raise TaichiSyntaxError(
Expand Down Expand Up @@ -1324,8 +1332,11 @@ def build_IfExp(ctx, node):
warnings.warn_explicit(
'Using conditional expression for element-wise select operation on '
'Taichi vectors/matrices is deprecated. '
'Please use "ti.select" instead.', DeprecationWarning,
ctx.file, node.lineno + ctx.lineno_offset)
'Please use "ti.select" instead.',
DeprecationWarning,
ctx.file,
node.lineno + ctx.lineno_offset,
module="taichi")
return node.ptr

is_static_if = (ASTTransformer.get_decorator(ctx,
Expand Down

0 comments on commit 7cab180

Please sign in to comment.