Skip to content

Commit

Permalink
Check if assignment target is a name when finding version
Browse files Browse the repository at this point in the history
Closes gh-343
  • Loading branch information
takluyver committed May 23, 2020
1 parent f75c3f7 commit 568227a
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions flit_core/flit_core/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,13 @@ def get_docstring_and_version_via_ast(target):
for child in node.body:
# Only use the version from the given module if it's a simple
# string assignment to __version__
is_version_str = (isinstance(child, ast.Assign) and
len(child.targets) == 1 and
child.targets[0].id == "__version__" and
isinstance(child.value, ast.Str))
is_version_str = (
isinstance(child, ast.Assign)
and len(child.targets) == 1
and isinstance(child.targets[0], ast.Name)
and child.targets[0].id == "__version__"
and isinstance(child.value, ast.Str)
)
if is_version_str:
version = child.value.s
break
Expand Down

0 comments on commit 568227a

Please sign in to comment.