Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
d30da5dd
Commit
d30da5dd
authored
May 29, 2019
by
Anthony Sottile
Committed by
Miss Islington (bot)
May 29, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bpo-36983: Fix typing.__all__ and add test for exported names (GH-13456)
https://bugs.python.org/issue36983
parent
34f4f5ef
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
0 deletions
+29
-0
Lib/test/test_typing.py
Lib/test/test_typing.py
+24
-0
Lib/typing.py
Lib/typing.py
+3
-0
Misc/NEWS.d/next/Library/2019-05-20-20-41-30.bpo-36983.hz-fLr.rst
...S.d/next/Library/2019-05-20-20-41-30.bpo-36983.hz-fLr.rst
+2
-0
No files found.
Lib/test/test_typing.py
View file @
d30da5dd
...
...
@@ -3605,6 +3605,30 @@ class AllTests(BaseTestCase):
self
.
assertIn
(
'SupportsBytes'
,
a
)
self
.
assertIn
(
'SupportsComplex'
,
a
)
def
test_all_exported_names
(
self
):
import
typing
actual_all
=
set
(
typing
.
__all__
)
computed_all
=
{
k
for
k
,
v
in
vars
(
typing
).
items
()
# explicitly exported, not a thing with __module__
if
k
in
actual_all
or
(
# avoid private names
not
k
.
startswith
(
'_'
)
and
# avoid things in the io / re typing submodules
k
not
in
typing
.
io
.
__all__
and
k
not
in
typing
.
re
.
__all__
and
k
not
in
{
'io'
,
're'
}
and
# there's a few types and metaclasses that aren't exported
not
k
.
endswith
((
'Meta'
,
'_contra'
,
'_co'
))
and
not
k
.
upper
()
==
k
and
# but export all things that have __module__ == 'typing'
getattr
(
v
,
'__module__'
,
None
)
==
typing
.
__name__
)
}
self
.
assertSetEqual
(
computed_all
,
actual_all
)
if
__name__
==
'__main__'
:
main
()
Lib/typing.py
View file @
d30da5dd
...
...
@@ -35,6 +35,7 @@ __all__ = [
'Callable'
,
'ClassVar'
,
'Final'
,
'ForwardRef'
,
'Generic'
,
'Literal'
,
'Optional'
,
...
...
@@ -81,11 +82,13 @@ __all__ = [
'SupportsRound'
,
# Concrete collection types.
'ChainMap'
,
'Counter'
,
'Deque'
,
'Dict'
,
'DefaultDict'
,
'List'
,
'OrderedDict'
,
'Set'
,
'FrozenSet'
,
'NamedTuple'
,
# Not really a type.
...
...
Misc/NEWS.d/next/Library/2019-05-20-20-41-30.bpo-36983.hz-fLr.rst
0 → 100644
View file @
d30da5dd
Add missing names to ``typing.__all__``: ``ChainMap``, ``ForwardRef``,
``OrderedDict`` - by Anthony Sottile.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment