[issue30518] Import type aliases from another module

2017-06-03 Thread John Jackson

John Jackson added the comment:

Thanks for your response!  Yes, the problem was a circular definition.  I still 
have much to learn about Python...

--
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30518] Import type aliases from another module

2017-06-02 Thread Ivan Levkivskyi

Ivan Levkivskyi added the comment:

> Block = [int, Tuple[int]]
> Blocks = List[Block]

These are both invalid type aliases (I have no idea why PyCharm does not flag 
them, you could report this at PyCharm issue tracker). I am not sure what 
exactly you want. If you want a list of either integers or tuples of integers, 
then you should write for example:

Block = Union[int, Tuple[int, ...]]
Blocks = List[Block]

Concerning import, this is definitely not a problem with aliases. What I have 
noticed is that you write "I have a 'base' module ..." and then "from 
base_module import ...", if you have a module named base.py, then you should 
write:

from base import Blocks, Tags

Or maybe you just have an import cycle...

--
nosy: +levkivskyi

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30518] Import type aliases from another module

2017-05-30 Thread Jelle Zijlstra

Jelle Zijlstra added the comment:

This is likely an issue with the setup of your project, not with type aliases. 
You haven't given enough information to tell me what the real problem is.

I'm not sure what you mean by "I still can't compile 'Blocks'".

--
nosy: +Jelle Zijlstra

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30518] Import type aliases from another module

2017-05-30 Thread John Jackson

John Jackson added the comment:

I just found out that the problem is even worse.  While PyCharm accepts the 
syntax below, I still can't compile 'Blocks'.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30518] Import type aliases from another module

2017-05-30 Thread John Jackson

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 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com