This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: The typing module includes 're' and 'io' in __all__
Type: behavior Stage:
Components: Versions: Python 3.6, Python 3.5
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: gvanrossum Nosy List: gvanrossum, larry, martin.panter, ned.deily, python-dev
Priority: release blocker Keywords:

Created on 2016-01-29 00:07 by gvanrossum, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (8)
msg259177 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2016-01-29 00:07
If you write "from typing import *" you get "re" and "io" for free, which is surprising if this import occurs after an actual "import re" or "import io".

The solution is not to include those two in __all__. You can still use them -- use "from typing import re" explicitly or reference them as "".

Because typing is provisional I'll fix this in 3.5.2 as well.
msg259178 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2016-01-29 00:10
msg259182 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2016-01-29 01:32
I would argue against changing this. They seem to be documented classes, so I guess this would break pydoc. It is a similar situation to, threading.enumerate(), etc. But I don’t have a strong opinion, and accept other people like keeping __all__ a minimal set of names and not reflecting the full API.
msg259191 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2016-01-29 03:37
Well, PEP 484 and are provisional. So small changes, even to documented behavior, are fine.  (I'm also changing @overload, per the change in PEP 484 that was discussed recently.)

Can you suggest a doc change?
msg259193 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2016-01-29 04:21
My concern with pydoc is that currently when you do “python -m pydoc typing” you get stuff like

        [. . .]
    io = class
     |  Wrapper namespace for IO generic classes.
     |  [. . .]
    re = class
     |  Wrapper namespace for re type aliases.
     |  [. . .]

If I comment out these two entries from typing.__all__, there is no longer any mention of “re” or “io” in the pydoc output.
msg259195 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2016-01-29 05:07
I'm no expert on pydoc, but I don't think it should be a reason to
keep these two names in __all__; __all__ is there primarily to guide
"import *" and it's clear that "from typing import *" overwriting a
previously-imported re or io module is a bad idea.

But maybe pydoc just needs to learn to look for another variable in
addition to __all__? Maybe __alldoc__?
msg259225 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2016-01-30 00:03
The __alldoc__ is an interesting idea to think about. Anyway, I haven’t actually tried the typing module yet, so I will let you decide the best way forward.
msg262911 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2016-04-05 15:35
New changeset be3c4151d9bf by Guido van Rossum in branch '3.5':
Many changes from the upstream repo (
Date User Action Args
2022-04-11 14:58:26adminsetnosy: + ned.deily, larry
github: 70422
2016-04-05 15:37:30gvanrossumsetstatus: open -> closed
resolution: fixed
2016-04-05 15:35:48python-devsetnosy: + python-dev
messages: + msg262911
2016-01-30 00:03:44martin.pantersetmessages: + msg259225
2016-01-29 05:07:30gvanrossumsetmessages: + msg259195
2016-01-29 04:21:38martin.pantersetmessages: + msg259193
2016-01-29 03:37:19gvanrossumsetmessages: + msg259191
2016-01-29 01:32:46martin.pantersetnosy: + martin.panter
messages: + msg259182
2016-01-29 00:10:30gvanrossumsetassignee: gvanrossum
type: behavior
2016-01-29 00:10:00gvanrossumsetmessages: + msg259178
2016-01-29 00:07:33gvanrossumcreate