Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
4aa30066
Kaydet (Commit)
4aa30066
authored
Haz 08, 2018
tarafından
Dong-hee Na
Kaydeden (comit)
Yury Selivanov
Haz 08, 2018
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
bpo-33197: Add description property for _ParameterKind. (GH-7206)
üst
ee994d74
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
6 deletions
+25
-6
inspect.rst
Doc/library/inspect.rst
+17
-0
inspect.py
Lib/inspect.py
+7
-6
2018-05-30-00-26-05.bpo-33197.XkE2kL.rst
...S.d/next/Library/2018-05-30-00-26-05.bpo-33197.XkE2kL.rst
+1
-0
No files found.
Doc/library/inspect.rst
Dosyayı görüntüle @
4aa30066
...
...
@@ -752,6 +752,23 @@ function.
... print('Parameter:', param)
Parameter: c
.. attribute:: Parameter.kind.description
Describes a enum value of Parameter.kind.
Example: print all descriptions of arguments::
>>> def foo(a, b, *, c, d=10):
... pass
>>> sig = signature(foo)
>>> for param in sig.parameters.values():
... print(param.kind.description)
positional or keyword
positional or keyword
keyword-only
keyword-only
.. method:: Parameter.replace(*[, name][, kind][, default][, annotation])
Create a new Parameter instance based on the instance replaced was invoked
...
...
Lib/inspect.py
Dosyayı görüntüle @
4aa30066
...
...
@@ -2395,6 +2395,9 @@ class _ParameterKind(enum.IntEnum):
def
__str__
(
self
):
return
self
.
_name_
@property
def
description
(
self
):
return
_PARAM_NAME_MAPPING
[
self
]
_POSITIONAL_ONLY
=
_ParameterKind
.
POSITIONAL_ONLY
_POSITIONAL_OR_KEYWORD
=
_ParameterKind
.
POSITIONAL_OR_KEYWORD
...
...
@@ -2410,8 +2413,6 @@ _PARAM_NAME_MAPPING = {
_VAR_KEYWORD
:
'variadic keyword'
}
_get_paramkind_descr
=
_PARAM_NAME_MAPPING
.
__getitem__
class
Parameter
:
"""Represents a parameter in a function signature.
...
...
@@ -2453,7 +2454,7 @@ class Parameter:
if
default
is
not
_empty
:
if
self
.
_kind
in
(
_VAR_POSITIONAL
,
_VAR_KEYWORD
):
msg
=
'{} parameters cannot have default values'
msg
=
msg
.
format
(
_get_paramkind_descr
(
self
.
_kind
)
)
msg
=
msg
.
format
(
self
.
_kind
.
description
)
raise
ValueError
(
msg
)
self
.
_default
=
default
self
.
_annotation
=
annotation
...
...
@@ -2475,7 +2476,7 @@ class Parameter:
'implicit arguments must be passed as '
'positional or keyword arguments, not {}'
)
msg
=
msg
.
format
(
_get_paramkind_descr
(
self
.
_kind
)
)
msg
=
msg
.
format
(
self
.
_kind
.
description
)
raise
ValueError
(
msg
)
self
.
_kind
=
_POSITIONAL_ONLY
name
=
'implicit{}'
.
format
(
name
[
1
:])
...
...
@@ -2751,8 +2752,8 @@ class Signature:
'wrong parameter order: {} parameter before {} '
'parameter'
)
msg
=
msg
.
format
(
_get_paramkind_descr
(
top_kind
)
,
_get_paramkind_descr
(
kind
)
)
msg
=
msg
.
format
(
top_kind
.
description
,
kind
.
description
)
raise
ValueError
(
msg
)
elif
kind
>
top_kind
:
kind_defaults
=
False
...
...
Misc/NEWS.d/next/Library/2018-05-30-00-26-05.bpo-33197.XkE2kL.rst
0 → 100644
Dosyayı görüntüle @
4aa30066
Add description property for _ParameterKind
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