Sourcery Starbot ⭐ refactored sambarnes/factom-core#19
Conversation
| def __post_init__(self): | ||
| assert len(self.chain_id) == 32, "chain_id must be a bytes object of length 32" | ||
| assert self.hash_type == 0 or self.hash_type == 1, "hash_type must be 0 (p2pkh) or 1 (p2sh)" | ||
| assert self.hash_type in [0, 1], "hash_type must be 0 (p2pkh) or 1 (p2sh)" |
There was a problem hiding this comment.
Function AddFederatedServerBitcoinAnchorKey.__post_init__ refactored with the following changes:
- Replace multiple comparisons of same variable with
inoperator
| for i in range(input_count): | ||
| for _ in range(input_count): | ||
| value, data = varint.decode(data) | ||
| fct_address, data = data[:32], data[32:] | ||
| inputs.append({"value": value, "fct_address": fct_address}) | ||
|
|
||
| outputs = [] | ||
| for i in range(output_count): | ||
| for _ in range(output_count): | ||
| value, data = varint.decode(data) | ||
| fct_address, data = data[:32], data[32:] | ||
| outputs.append({"value": value, "fct_address": fct_address}) | ||
|
|
||
| ec_purchases = [] | ||
| for i in range(ec_purchase_count): | ||
| for _ in range(ec_purchase_count): | ||
| value, data = varint.decode(data) | ||
| ec_public_key, data = data[:32], data[32:] | ||
| ec_purchases.append({"value": value, "ec_public_key": ec_public_key}) | ||
|
|
||
| rcds = primitives.FullSignatureList() | ||
| for i in range(input_count): | ||
| for _ in range(input_count): |
There was a problem hiding this comment.
Function FactoidTransaction.unmarshal_with_remainder refactored with the following changes:
- Replace unused for index with underscore
| v = 0 | ||
| for b in h: | ||
| v += b | ||
| v = sum(h) |
There was a problem hiding this comment.
Function Blockchain.vm_for_hash refactored with the following changes:
- Convert for loop into call to sum()
- Simplify generator expression
| data = raw | ||
| messages = [] | ||
| for i in range(message_count): | ||
| for _ in range(message_count): |
There was a problem hiding this comment.
Function AdminBlockBody.unmarshal_with_remainder refactored with the following changes:
- Replace unused for index with underscore
- Use previously assigned local variable
| for i in range(header.message_count): | ||
| for _ in range(header.message_count): |
There was a problem hiding this comment.
Function AdminBlock.unmarshal_with_remainder refactored with the following changes:
- Replace unused for index with underscore
- Use previously assigned local variable
| length, data = struct.unpack(">I", raw[:4])[0], raw[4:] | ||
| signatures = [] | ||
| for i in range(length): | ||
| for _ in range(length): |
There was a problem hiding this comment.
Function FullSignatureList.unmarshal refactored with the following changes:
- Replace unused for index with underscore
|
|
||
| def build_merkle_tree(hashes: list): | ||
| if len(hashes) == 0 or len(hashes) == 1: | ||
| if len(hashes) in [0, 1]: |
There was a problem hiding this comment.
Function build_merkle_tree refactored with the following changes:
- Replace multiple comparisons of same variable with
inoperator
| buf.append(b) | ||
|
|
||
| h = h << 7 | ||
| h <<= 7 |
There was a problem hiding this comment.
Function encode refactored with the following changes:
- Replace assignment with augmented assignment
| while True: | ||
| i, data = ord(data[:1]), data[1:] | ||
| result = result << 7 | ||
| result <<= 7 |
There was a problem hiding this comment.
Function decode refactored with the following changes:
- Replace assignment with augmented assignment
| if not ParcelType.is_valid(parcel_type): | ||
| raise ValueError("Invalid parcel_type provided") | ||
| elif not type(address) is not str and address is not None: | ||
| elif type(address) is str and address is not None: |
There was a problem hiding this comment.
Function Parcel.__init__ refactored with the following changes:
- Simplify logical expression
Thanks for starring sourcery-ai/sourcery ✨ 🌟 ✨
Here's your pull request refactoring your most popular Python repo.
If you want Sourcery to refactor all your Python repos and incoming pull requests install our bot.
Review changes via command line
To manually merge these changes, make sure you're on the
masterbranch, then run: