diff --git a/flit_core/flit_core/common.py b/flit_core/flit_core/common.py index 828b26b8..32c2a0da 100644 --- a/flit_core/flit_core/common.py +++ b/flit_core/flit_core/common.py @@ -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 diff --git a/flit_core/flit_core/tests/samples/module2.py b/flit_core/flit_core/tests/samples/module2.py index cc83e39f..70c868b3 100644 --- a/flit_core/flit_core/tests/samples/module2.py +++ b/flit_core/flit_core/tests/samples/module2.py @@ -2,4 +2,9 @@ Docstring formatted like this. """ +a = {} +# An assignment to a subscript (a['test']) broke introspection +# https://github.com/takluyver/flit/issues/343 +a['test'] = 6 + __version__ = '7.0'