Changes based on style and lint checks. (final_code_quality_3) #1356
No reviewers
Labels
No Label
bug
build
dependencies
developers
documentation
duplicate
enhancement
formatting
invalid
legal
mobile
obsolete
packaging
performance
protocol
question
refactoring
regression
security
test
translation
usability
wontfix
No Milestone
No project
No Assignees
1 Participants
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: Bitmessage/PyBitmessage-2024-12-05#1356
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "final_code_quality_3"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Changes based on style and lint checks. (final_code_quality_3)
Please amend the docstrings based on my feedback. About two are left, which I'm unsure about and will have to check.
@ -9,3 +16,4 @@
class ProcessingError(Exception):
"""General class for protocol parser exception, use as a base for others."""
pass
General class for protocol parser exception, use as a base for others.
@ -13,2 +21,4 @@
class UnknownStateError(ProcessingError):
"""Parser points to an unknown (unimplemented) state."""
pass
Parser points to an unknown (unimplemented) state.
@ -16,2 +27,3 @@
class AdvancedDispatcher(asyncore.dispatcher):
_buf_len = 131072 # 128kB
"""Improved version of asyncore dispatcher, with buffers and protocol state."""
# pylint: disable=too-many-instance-attributes
Improved version of asyncore dispatcher, with buffers and protocol state.
Append binary data to the end of stream write buffer.
@ -82,2 +99,4 @@
self.state = state_str
def writable(self):
"""Is data from the write buffer ready to be sent to the network?"""
Cut the beginning of the stream write buffer.
Cut the beginning of the stream read buffer.
@ -112,3 +133,4 @@
def handle_write(self):
"""Send outgoing data from write buffer."""
self.lastTx = time.time()
Process (parse) data that's in the buffer, as long as there is enough data and the connection is open.
Set the next processing state.
Is data from the write buffer ready to be sent to the network?
Is the read buffer ready to accept data from the network?
Append incoming data to the read buffer.
Send outgoing data from write buffer.
Callback for connection established event.
Signal to the processing loop to end.
@ -11,3 +17,4 @@
class BMObjectInsufficientPOWError(Exception):
"""Exception indicating the object doesn't have sufficient proof of work."""
errorCodes = ("Insufficient proof of work")
Exception indicating the object doesn't have sufficient proof of work.
@ -15,3 +22,4 @@
class BMObjectInvalidDataError(Exception):
"""Exception indicating the data being parsed does not match the specification."""
errorCodes = ("Data invalid")
Exception indicating the data being parsed does not match the specification.
@ -19,3 +27,4 @@
class BMObjectExpiredError(Exception):
"""Exception indicating the object's lifetime has expired."""
errorCodes = ("Object expired")
Exception indicating the object's lifetime has expired.
@ -23,3 +32,4 @@
class BMObjectUnwantedStreamError(Exception):
"""Exception indicating the object is in a stream we didn't advertise as being interested in."""
errorCodes = ("Object in unwanted stream")
Exception indicating the object is in a stream we didn't advertise as being interested in.
@ -27,3 +37,4 @@
class BMObjectInvalidError(Exception):
"""The object's data does not match object specification."""
errorCodes = ("Invalid object")
The object's data does not match object specification.
@ -31,3 +42,4 @@
class BMObjectAlreadyHaveError(Exception):
"""We received a duplicate object (one we already have)"""
errorCodes = ("Already have this object")
We received a duplicate object (one we already have)
@ -35,1 +47,4 @@
class BMObject(object):
"""Bitmessage Object as a class."""
# pylint: disable=too-many-instance-attributes
Bitmessage Object as a class.
@ -108,1 +148,3 @@
logger.debug('The payload length of this broadcast packet is unreasonably low. Someone is probably trying funny business. Ignoring message.')
logger.debug(
'The payload length of this broadcast packet is unreasonably low.'
' Someone is probably trying funny business. Ignoring message.')
Perform a proof of work check for sufficiency.
Check if object's lifetime isn't ridiculously far in the past or future.
Check if object's stream matches streams we are interested in
Check if we already have the object (so that we don't duplicate it in inventory or advertise it unnecessarily)
Call a object type specific check (objects can have additional checks based on their types)
"Message" object type checks.
"Getpubkey" object type checks.
"Pubkey" object type checks.
"Broadcast" object type checks.
All supplied docstrings added. One relative import made less relative.
Base class for handling connection established implementations.
Callback for connection being closed, but can also be called directly when you want connection to close.
I updated the last 2 missing docstrings, just add those and rebase and it's ready to go.
Guessing you meant 'method' instead of 'base class' there.