Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Dec 13, 2022
1 parent e720ffc commit 4ddf05f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
7 changes: 5 additions & 2 deletions python/taichi/lang/_wrap_inspect.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
_builtin_getfile = inspect.getfile
_builtin_findsource = inspect.findsource


def check_use_sourceinspect():
return int(os.getenv('USE_SOURCEINSPECT', 0)) == 1

Expand Down Expand Up @@ -130,7 +131,8 @@ def __exit__(self, *_):

def getsourcelines(obj):
if check_use_sourceinspect():
warnings.warn('Sourceinspect is deprecated since v1.4.0', DeprecationWarning)
warnings.warn('Sourceinspect is deprecated since v1.4.0',
DeprecationWarning)
return sourceinspect.getsourcelines(obj)

try:
Expand All @@ -147,7 +149,8 @@ def getsourcelines(obj):

def getsourcefile(obj):
if check_use_sourceinspect():
warnings.warn('Sourceinspect is deprecated since v1.4.0', DeprecationWarning)
warnings.warn('Sourceinspect is deprecated since v1.4.0',
DeprecationWarning)
return sourceinspect.getsourcefile(obj)

try:
Expand Down
2 changes: 1 addition & 1 deletion python/taichi/lang/ast/checkers.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import ast

from taichi.lang.exception import TaichiSyntaxError
from taichi.lang._wrap_inspect import getsourcefile, getsourcelines
from taichi.lang.exception import TaichiSyntaxError


class KernelSimplicityASTChecker(ast.NodeVisitor):
Expand Down
9 changes: 3 additions & 6 deletions tests/python/test_deprecation.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,11 +175,8 @@ def ker(tex: ti.types.rw_texture(num_dimensions=2, lod=0)):


def test_deprecated_source_inspect():
with pytest.warns(
DeprecationWarning,
match=
"Sourceinspect is deprecated since v1.4.0"
):
with pytest.warns(DeprecationWarning,
match="Sourceinspect is deprecated since v1.4.0"):
import os
os.environ['USE_SOURCEINSPECT'] = '1'
from taichi.lang._wrap_inspect import getsourcelines
Expand All @@ -188,4 +185,4 @@ def test_deprecated_source_inspect():
def func():
pass

print(getsourcelines(func))
print(getsourcelines(func))

0 comments on commit 4ddf05f

Please sign in to comment.