Skip to content

Commit

Permalink
provide two quick fixes for type inference module
Browse files Browse the repository at this point in the history
  • Loading branch information
Hynn01 committed May 26, 2022
1 parent f19371d commit 77ef3c1
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
5 changes: 4 additions & 1 deletion dslinter/utils/ast.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,4 +228,7 @@ def _get_target_name(target: astroid.node_classes.NodeNG) -> str:
return target.name
if hasattr(target, "value"):
return AssignUtil._get_target_name(target.value)
raise Exception("Target name cannot be retrieved.")
# raise Exception("Target name cannot be retrieved.")
# This is a quick fix
# TODO: make a stable fix
return ""
2 changes: 1 addition & 1 deletion dslinter/utils/type_inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def line_to_add_call(node: astroid.node_classes.NodeNG):
:param node: The node where a call is added to in the source code.
:return: Line number where the reveal_type() call can be added.
"""
if hasattr(node.parent, "blockstart_tolineno") and node not in node.parent.body:
if hasattr(node.parent, "blockstart_tolineno") and node not in node.parent.body and len(node.parent.body) > 0:
return TypeInference.line_to_add_call(node.parent.body[0])
return node.tolineno

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ skip = 'scripts'

[tool.poetry]
name = "dslinter"
version = "2.0.7"
version = "2.0.8"
description = "`dslinter` is a pylint plugin for linting data science and machine learning code. We plan to support the following Python libraries: TensorFlow, PyTorch, Scikit-Learn, Pandas, NumPy and SciPy."

license = "GPL-3.0 License"
Expand Down

0 comments on commit 77ef3c1

Please sign in to comment.