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
48a724fa
Kaydet (Commit)
48a724fa
authored
Nis 12, 2015
tarafından
Ethan Furman
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Close issue23900: add default __doc__ to new enumerations that do not specify one.
üst
a1c7e727
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
5 deletions
+9
-5
enum.py
Lib/enum.py
+4
-0
test_enum.py
Lib/test/test_enum.py
+5
-5
No files found.
Lib/enum.py
Dosyayı görüntüle @
48a724fa
...
...
@@ -106,6 +106,10 @@ class EnumMeta(type):
raise
ValueError
(
'Invalid enum member name: {0}'
.
format
(
','
.
join
(
invalid_names
)))
# create a default docstring if one has not been provided
if
'__doc__'
not
in
classdict
:
classdict
[
'__doc__'
]
=
'An enumeration.'
# create our new Enum type
enum_class
=
super
()
.
__new__
(
metacls
,
cls
,
bases
,
classdict
)
enum_class
.
_member_names_
=
[]
# names in definition order
...
...
Lib/test/test_enum.py
Dosyayı görüntüle @
48a724fa
...
...
@@ -1560,9 +1560,7 @@ expected_help_output_with_docs = """\
Help on class Color in module
%
s:
class Color(enum.Enum)
| Generic enumeration.
|
\x20\x20
| Derive from this class to define new enumerations.
| An enumeration.
|
\x20\x20
| Method resolution order:
| Color
...
...
@@ -1626,6 +1624,8 @@ class Color(enum.Enum)
class
TestStdLib
(
unittest
.
TestCase
):
maxDiff
=
None
class
Color
(
Enum
):
red
=
1
green
=
2
...
...
@@ -1646,7 +1646,7 @@ class TestStdLib(unittest.TestCase):
def
test_inspect_getmembers
(
self
):
values
=
dict
((
(
'__class__'
,
EnumMeta
),
(
'__doc__'
,
None
),
(
'__doc__'
,
'An enumeration.'
),
(
'__members__'
,
self
.
Color
.
__members__
),
(
'__module__'
,
__name__
),
(
'blue'
,
self
.
Color
.
blue
),
...
...
@@ -1674,7 +1674,7 @@ class TestStdLib(unittest.TestCase):
Attribute
(
name
=
'__class__'
,
kind
=
'data'
,
defining_class
=
object
,
object
=
EnumMeta
),
Attribute
(
name
=
'__doc__'
,
kind
=
'data'
,
defining_class
=
self
.
Color
,
object
=
None
),
defining_class
=
self
.
Color
,
object
=
'An enumeration.'
),
Attribute
(
name
=
'__members__'
,
kind
=
'property'
,
defining_class
=
EnumMeta
,
object
=
EnumMeta
.
__members__
),
Attribute
(
name
=
'__module__'
,
kind
=
'data'
,
...
...
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