[issue30518] Import type aliases from another module

John Jackson report at bugs.python.org
Tue May 30 22:54:11 EDT 2017


New submission from John Jackson:

I have a 'base' module where I define some type aliases, such as:

    from typing import List, Tuple
    Block = [int, Tuple[int]]
    Blocks = List[Block]
    Tags = List[str]

I would like to import these aliases into other modules so that the 'base' module provides the definitive alias.

Currently, if I attempt to import the type aliases using:

    from base_module import Tags, Blocks

Pycharm shows no error, but when I attempt to execute the code I get the error:

    ImportError: cannot import name 'Tags'

I see that there has been some discussion related to this in 2015, but I can't find any documentation saying that something like this has been implemented.

----------
components: Build
messages: 294807
nosy: Paragape
priority: normal
severity: normal
status: open
title: Import type aliases from another module
type: enhancement
versions: Python 3.5

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue30518>
_______________________________________


More information about the Python-bugs-list mailing list