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
762b9571
Commit
762b9571
authored
Nov 16, 2017
by
Dong-hee Na
Committed by
Yury Selivanov
Nov 15, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bpo-32018: Fix inspect.signature repr to follow PEP 8 (#4408)
parent
f8a4c03e
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
10 additions
and
5 deletions
+10
-5
Lib/inspect.py
Lib/inspect.py
+5
-2
Lib/test/test_inspect.py
Lib/test/test_inspect.py
+2
-2
Lib/test/test_pydoc.py
Lib/test/test_pydoc.py
+1
-1
Misc/NEWS.d/next/Library/2017-11-16-02-32-41.bpo-32018.YMQ7Q2.rst
...S.d/next/Library/2017-11-16-02-32-41.bpo-32018.YMQ7Q2.rst
+2
-0
No files found.
Lib/inspect.py
View file @
762b9571
...
...
@@ -2521,11 +2521,14 @@ class Parameter:
# Add annotation and default value
if
self
.
_annotation
is
not
_empty
:
formatted
=
'{}:{}'
.
format
(
formatted
,
formatted
=
'{}:
{}'
.
format
(
formatted
,
formatannotation
(
self
.
_annotation
))
if
self
.
_default
is
not
_empty
:
formatted
=
'{}={}'
.
format
(
formatted
,
repr
(
self
.
_default
))
if
self
.
_annotation
is
not
_empty
:
formatted
=
'{} = {}'
.
format
(
formatted
,
repr
(
self
.
_default
))
else
:
formatted
=
'{}={}'
.
format
(
formatted
,
repr
(
self
.
_default
))
if
kind
==
_VAR_POSITIONAL
:
formatted
=
'*'
+
formatted
...
...
Lib/test/test_inspect.py
View file @
762b9571
...
...
@@ -2875,12 +2875,12 @@ class TestSignatureObject(unittest.TestCase):
def
foo
(
a
:
int
=
1
,
*
,
b
,
c
=
None
,
**
kwargs
)
->
42
:
pass
self
.
assertEqual
(
str
(
inspect
.
signature
(
foo
)),
'(a:
int=
1, *, b, c=None, **kwargs) -> 42'
)
'(a:
int =
1, *, b, c=None, **kwargs) -> 42'
)
def
foo
(
a
:
int
=
1
,
*
args
,
b
,
c
=
None
,
**
kwargs
)
->
42
:
pass
self
.
assertEqual
(
str
(
inspect
.
signature
(
foo
)),
'(a:
int=
1, *args, b, c=None, **kwargs) -> 42'
)
'(a:
int =
1, *args, b, c=None, **kwargs) -> 42'
)
def
foo
():
pass
...
...
Lib/test/test_pydoc.py
View file @
762b9571
...
...
@@ -824,7 +824,7 @@ class TestDescriptions(unittest.TestCase):
T
=
typing
.
TypeVar
(
'T'
)
class
C
(
typing
.
Generic
[
T
],
typing
.
Mapping
[
int
,
str
]):
...
self
.
assertEqual
(
pydoc
.
render_doc
(
foo
).
splitlines
()[
-
1
],
'f
\
x08
fo
\
x08
oo
\
x08
o(data:
List[Any], x:
int)'
'f
\
x08
fo
\
x08
oo
\
x08
o(data:
List[Any], x:
int)'
' -> Iterator[Tuple[int, Any]]'
)
self
.
assertEqual
(
pydoc
.
render_doc
(
C
).
splitlines
()[
2
],
'class C
\
x08
C(typing.Mapping)'
)
...
...
Misc/NEWS.d/next/Library/2017-11-16-02-32-41.bpo-32018.YMQ7Q2.rst
0 → 100644
View file @
762b9571
inspect.signature should follow PEP 8, if the parameter has an annotation and a
default value. Patch by Dong-hee Na.
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