Skip to content

Commit

Permalink
[bug] Fix warnings on external functions on windows (#4079)
Browse files Browse the repository at this point in the history
* [bug] Fix warnings on external functions on windows

* fix pylint

* fix
  • Loading branch information
lin-hitonami authored and Ailing Zhang committed Jan 25, 2022
1 parent 17c124d commit 9d0973e
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions python/taichi/lang/ast/ast_transformer.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
import ast
import collections.abc
import inspect
import os
import warnings
from collections import ChainMap
from sys import version_info

import astor
from taichi._lib import core as _ti_core
from taichi._lib.utils import package_root
from taichi.lang import expr, impl, kernel_arguments, kernel_impl, matrix, mesh
from taichi.lang import ops as ti_ops
from taichi.lang._ndrange import ndrange
Expand Down Expand Up @@ -342,14 +339,9 @@ def warn_if_is_external_func(ctx, node):
if hasattr(func, "_is_taichi_function") or hasattr(
func, "_is_wrapped_kernel"): # taichi func/kernel
return
if hasattr(func, "is_taichi_class"): # Matrix/Struct
return
try:
file = inspect.getfile(inspect.getmodule(func))
except TypeError:
file = None
if file and os.path.commonpath(
[file, package_root]) == package_root: # functions inside taichi
if hasattr(
func, "__module__"
) and func.__module__ and func.__module__.startswith("taichi."):
return
name = unparse(node.func).strip()
warnings.warn_explicit(
Expand Down Expand Up @@ -384,7 +376,9 @@ def build_Call(ctx, node):
node.func.value.ptr, str) and node.func.attr == 'format':
args.insert(0, node.func.value.ptr)
node.ptr = impl.ti_format(*args, **keywords)
elif ASTTransformer.build_call_if_is_builtin(node, args, keywords):
return node.ptr

if ASTTransformer.build_call_if_is_builtin(node, args, keywords):
return node.ptr

node.ptr = func(*args, **keywords)
Expand Down

0 comments on commit 9d0973e

Please sign in to comment.