Skip to content
This repository was archived by the owner on May 23, 2023. It is now read-only.

Commit 008357a

Browse files
committed
Fixed Docstrings to apply PEP 257 convention
1 parent 0c9996c commit 008357a

File tree

6 files changed

+71
-71
lines changed

6 files changed

+71
-71
lines changed

ethereum/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242

4343
# ########### endversion ##################
4444

45-
'''from ethereum import utils
45+
"""from ethereum import utils
4646
from ethereum import trie
4747
from ethereum import securetrie
4848
from ethereum import blocks
@@ -51,4 +51,4 @@
5151
from ethereum import tester
5252
from ethereum import abi
5353
from ethereum import keys
54-
from ethereum import ethash'''
54+
from ethereum import ethash"""

ethereum/abi.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ def event_id(name, encode_types):
135135

136136

137137
def decint(n, signed=False): # pylint: disable=invalid-name,too-many-branches
138-
''' Decode an unsigned/signed integer. '''
138+
""" Decode an unsigned/signed integer. """
139139

140140
if isinstance(n, str):
141141
n = utils.to_string(n)
@@ -185,7 +185,7 @@ def decint(n, signed=False): # pylint: disable=invalid-name,too-many-branches
185185

186186

187187
def encode_single(typ, arg): # pylint: disable=too-many-return-statements,too-many-branches,too-many-statements,too-many-locals
188-
''' Encode `arg` as `typ`.
188+
""" Encode `arg` as `typ`.
189189
190190
`arg` will be encoded in a best effort manner, were necessary the function
191191
will try to correctly define the underlying binary representation (ie.
@@ -223,7 +223,7 @@ def encode_single(typ, arg): # pylint: disable=too-many-return-statements,too-m
223223
Note:
224224
This function don't work with array types, for that use the `enc`
225225
function.
226-
'''
226+
"""
227227
base, sub, _ = typ
228228

229229
if base == 'uint':

ethereum/experimental/pruning_trie.py

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -168,9 +168,9 @@ def unpack_to_nibbles(bindata):
168168

169169

170170
def starts_with(full, part):
171-
''' test whether the items in the part is
171+
""" test whether the items in the part is
172172
the leading items of the full
173-
'''
173+
"""
174174
if len(full) < len(part):
175175
return False
176176
return full[:len(part)] == part
@@ -200,11 +200,11 @@ def transient_trie_exception(*args):
200200
class Trie(object):
201201

202202
def __init__(self, db, root_hash=BLANK_ROOT, transient=False):
203-
'''it also present a dictionary like interface
203+
"""it also present a dictionary like interface
204204
205205
:param db key value database
206206
:root: blank or trie node in form of [key, value] or [v0,v1..v15,v]
207-
'''
207+
"""
208208
self.db = db # Pass in a database object directly
209209
self.transient = transient
210210
if self.transient:
@@ -215,11 +215,11 @@ def __init__(self, db, root_hash=BLANK_ROOT, transient=False):
215215
self.journal = []
216216

217217
# def __init__(self, dbfile, root_hash=BLANK_ROOT):
218-
# '''it also present a dictionary like interface
218+
# """it also present a dictionary like interface
219219

220220
# :param dbfile: key value database
221221
# :root: blank or trie node in form of [key, value] or [v0,v1..v15,v]
222-
# '''
222+
# """
223223
# if isinstance(dbfile, str):
224224
# dbfile = os.path.abspath(dbfile)
225225
# self.db = DB(dbfile)
@@ -251,8 +251,8 @@ def spv_storing(self, node):
251251

252252
@property
253253
def root_hash(self):
254-
'''always empty or a 32 bytes string
255-
'''
254+
"""always empty or a 32 bytes string
255+
"""
256256
return self.get_root_hash()
257257

258258
def get_root_hash(self):
@@ -311,8 +311,8 @@ def all_nodes(self, node=None):
311311
# return o
312312

313313
def clear(self):
314-
''' clear all tree data
315-
'''
314+
""" clear all tree data
315+
"""
316316
self._delete_child_storage(self.root_node)
317317
self._delete_node_storage(self.root_node)
318318
self.root_node = BLANK_NODE
@@ -349,11 +349,11 @@ def _decode_to_node(self, encoded):
349349
return o
350350

351351
def _get_node_type(self, node):
352-
''' get node type and content
352+
""" get node type and content
353353
354354
:param node: node in form of list, or BLANK_NODE
355355
:return: node type
356-
'''
356+
"""
357357
if node == BLANK_NODE:
358358
return NODE_TYPE_BLANK
359359

@@ -603,9 +603,9 @@ def prev(self, key):
603603
return nibbles_to_bin(o) if o else None
604604

605605
def _delete_node_storage(self, node, is_root=False):
606-
'''delete storage
606+
"""delete storage
607607
:param node: node in form of list, or BLANK_NODE
608-
'''
608+
"""
609609
if node == BLANK_NODE:
610610
return
611611
# assert isinstance(node, list)
@@ -645,8 +645,8 @@ def _delete(self, node, key):
645645

646646
def _normalize_branch_node(self, node):
647647
# sys.stderr.write('nbn\n')
648-
'''node should have only one item changed
649-
'''
648+
"""node should have only one item changed
649+
"""
650650
not_blank_items_count = sum(1 for x in range(17) if node[x])
651651
assert not_blank_items_count >= 1
652652

@@ -772,9 +772,9 @@ def _delete_kv_node(self, node, key):
772772
assert False
773773

774774
def delete(self, key):
775-
'''
775+
"""
776776
:param key: a string with length of [0, 32]
777-
'''
777+
"""
778778
if not is_string(key):
779779
raise Exception("Key must be string")
780780

@@ -808,10 +808,10 @@ def clear_all(self, node=None):
808808
self.clear_all(self._decode_to_node(node[i]))
809809

810810
def _get_size(self, node):
811-
'''Get counts of (key, value) stored in this and the descendant nodes
811+
"""Get counts of (key, value) stored in this and the descendant nodes
812812
813813
:param node: node in form of list, or BLANK_NODE
814-
'''
814+
"""
815815
if node == BLANK_NODE:
816816
return 0
817817

@@ -830,15 +830,15 @@ def _get_size(self, node):
830830
return sum(sizes)
831831

832832
def _to_dict(self, node):
833-
'''convert (key, value) stored in this and the descendant nodes
833+
"""convert (key, value) stored in this and the descendant nodes
834834
to dict items.
835835
836836
:param node: node in form of list, or BLANK_NODE
837837
838838
.. note::
839839
840840
Here key is in full form, rather than key of the individual node
841-
'''
841+
"""
842842
if node == BLANK_NODE:
843843
return {}
844844

@@ -894,12 +894,12 @@ def iter_branch(self):
894894
yield key, value
895895

896896
def _iter_branch(self, node):
897-
'''yield (key, value) stored in this and the descendant nodes
897+
"""yield (key, value) stored in this and the descendant nodes
898898
:param node: node in form of list, or BLANK_NODE
899899
900900
.. note::
901901
Here key is in full form, rather than key of the individual node
902-
'''
902+
"""
903903
if node == BLANK_NODE:
904904
raise StopIteration
905905

@@ -949,10 +949,10 @@ def __contains__(self, key):
949949
return self.get(key) != BLANK_NODE
950950

951951
def update(self, key, value):
952-
'''
952+
"""
953953
:param key: a string
954954
:value: a string
955-
'''
955+
"""
956956
if not is_string(key):
957957
raise Exception("Key must be string")
958958

ethereum/trie.py

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,9 @@ def unpack_to_nibbles(bindata):
112112

113113

114114
def starts_with(full, part):
115-
''' test whether the items in the part is
115+
""" test whether the items in the part is
116116
the leading items of the full
117-
'''
117+
"""
118118
if len(full) < len(part):
119119
return False
120120
return full[:len(part)] == part
@@ -140,20 +140,20 @@ def is_key_value_type(node_type):
140140
class Trie(object):
141141

142142
def __init__(self, db, root_hash=BLANK_ROOT):
143-
'''it also present a dictionary like interface
143+
"""it also present a dictionary like interface
144144
145145
:param db key value database
146146
:root: blank or trie node in form of [key, value] or [v0,v1..v15,v]
147-
'''
147+
"""
148148
self.db = db # Pass in a database object directly
149149
self.set_root_hash(root_hash)
150150

151151
# def __init__(self, dbfile, root_hash=BLANK_ROOT):
152-
# '''it also present a dictionary like interface
152+
# """it also present a dictionary like interface
153153

154154
# :param dbfile: key value database
155155
# :root: blank or trie node in form of [key, value] or [v0,v1..v15,v]
156-
# '''
156+
# """
157157
# if isinstance(dbfile, str):
158158
# dbfile = os.path.abspath(dbfile)
159159
# self.db = DB(dbfile)
@@ -163,8 +163,8 @@ def __init__(self, db, root_hash=BLANK_ROOT):
163163

164164
@property
165165
def root_hash(self):
166-
'''always empty or a 32 bytes string
167-
'''
166+
"""always empty or a 32 bytes string
167+
"""
168168
return self._root_hash
169169

170170
def get_root_hash(self):
@@ -191,8 +191,8 @@ def set_root_hash(self, root_hash):
191191
self._root_hash = root_hash
192192

193193
def clear(self):
194-
''' clear all tree data
195-
'''
194+
""" clear all tree data
195+
"""
196196
self._delete_child_storage(self.root_node)
197197
self._delete_node_storage(self.root_node)
198198
self.root_node = BLANK_NODE
@@ -227,11 +227,11 @@ def _decode_to_node(self, encoded):
227227
return o
228228

229229
def _get_node_type(self, node):
230-
''' get node type and content
230+
""" get node type and content
231231
232232
:param node: node in form of list, or BLANK_NODE
233233
:return: node type
234-
'''
234+
"""
235235
if node == BLANK_NODE:
236236
return NODE_TYPE_BLANK
237237

@@ -592,9 +592,9 @@ def prev(self, key):
592592
return nibbles_to_bin(without_terminator(o)) if o else None
593593

594594
def _delete_node_storage(self, node):
595-
'''delete storage
595+
"""delete storage
596596
:param node: node in form of list, or BLANK_NODE
597-
'''
597+
"""
598598
if node == BLANK_NODE:
599599
return
600600
# assert isinstance(node, list)
@@ -631,8 +631,8 @@ def _delete(self, node, key):
631631
return self._delete_kv_node(node, key)
632632

633633
def _normalize_branch_node(self, node):
634-
'''node should have only one item changed
635-
'''
634+
"""node should have only one item changed
635+
"""
636636
not_blank_items_count = sum(1 for x in range(17) if node[x])
637637
assert not_blank_items_count >= 1
638638

@@ -729,9 +729,9 @@ def _delete_kv_node(self, node, key):
729729
assert False
730730

731731
def delete(self, key):
732-
'''
732+
"""
733733
:param key: a string with length of [0, 32]
734-
'''
734+
"""
735735
if not is_string(key):
736736
raise Exception("Key must be string")
737737

@@ -744,10 +744,10 @@ def delete(self, key):
744744
self._update_root_hash()
745745

746746
def _get_size(self, node):
747-
'''Get counts of (key, value) stored in this and the descendant nodes
747+
"""Get counts of (key, value) stored in this and the descendant nodes
748748
749749
:param node: node in form of list, or BLANK_NODE
750-
'''
750+
"""
751751
if node == BLANK_NODE:
752752
return 0
753753

@@ -766,12 +766,12 @@ def _get_size(self, node):
766766
return sum(sizes)
767767

768768
def _iter_branch(self, node):
769-
'''yield (key, value) stored in this and the descendant nodes
769+
"""yield (key, value) stored in this and the descendant nodes
770770
:param node: node in form of list, or BLANK_NODE
771771
772772
.. note::
773773
Here key is in full form, rather than key of the individual node
774-
'''
774+
"""
775775
if node == BLANK_NODE:
776776
raise StopIteration
777777

@@ -809,15 +809,15 @@ def iter_branch(self):
809809
yield key, value
810810

811811
def _to_dict(self, node):
812-
'''convert (key, value) stored in this and the descendant nodes
812+
"""convert (key, value) stored in this and the descendant nodes
813813
to dict items.
814814
815815
:param node: node in form of list, or BLANK_NODE
816816
817817
.. note::
818818
819819
Here key is in full form, rather than key of the individual node
820-
'''
820+
"""
821821
if node == BLANK_NODE:
822822
return {}
823823

@@ -885,10 +885,10 @@ def __contains__(self, key):
885885
return self.get(key) != BLANK_NODE
886886

887887
def update(self, key, value):
888-
'''
888+
"""
889889
:param key: a string
890890
:value: a string
891-
'''
891+
"""
892892
if not is_string(key):
893893
raise Exception("Key must be string")
894894

0 commit comments

Comments
 (0)