-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sourcery refactored master branch #1
base: master
Are you sure you want to change the base?
Conversation
cp = plt.Program("1.0.0", validator) | ||
return cp | ||
return plt.Program("1.0.0", validator) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function UPLCCompiler.visit_Module
refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
)
if ifs is None: | ||
ifs = self.visit(ifexpr) | ||
else: | ||
ifs = plt.And(ifs, self.visit(ifexpr)) | ||
ifs = self.visit(ifexpr) if ifs is None else plt.And(ifs, self.visit(ifexpr)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function UPLCCompiler.visit_ListComp
refactored with the following changes:
- Replace if statement with if expression (
assign-if-exp
)
[ | ||
txi.resolved.value.get(token.policy_id, {b"": 0}).get(token.token_name, 0) | ||
for txi in txins | ||
if txi.resolved.address == address | ||
] | ||
txi.resolved.value.get(token.policy_id, {b"": 0}).get( | ||
token.token_name, 0 | ||
) | ||
for txi in txins | ||
if txi.resolved.address == address |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function all_tokens_unlocked_from_address
refactored with the following changes:
- Replace unneeded comprehension with generator (
comprehension-to-generator
)
[ | ||
txo.value.get(token.policy_id, {b"": 0}).get(token.token_name, 0) | ||
for txo in txouts | ||
if txo.address == address and txo.datum == output_datum | ||
] | ||
txo.value.get(token.policy_id, {b"": 0}).get(token.token_name, 0) | ||
for txo in txouts | ||
if txo.address == address and txo.datum == output_datum |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function all_tokens_locked_at_address_with_datum
refactored with the following changes:
- Replace unneeded comprehension with generator (
comprehension-to-generator
)
[ | ||
txo.value.get(token.policy_id, {b"": 0}).get(token.token_name, 0) | ||
for txo in txouts | ||
if txo.address == address | ||
] | ||
txo.value.get(token.policy_id, {b"": 0}).get(token.token_name, 0) | ||
for txo in txouts | ||
if txo.address == address |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function all_tokens_locked_at_address
refactored with the following changes:
- Replace unneeded comprehension with generator (
comprehension-to-generator
)
for scope in reversed(self.guaranteed_avail_names): | ||
if name in scope: | ||
return True | ||
return False | ||
return any(name in scope for scope in reversed(self.guaranteed_avail_names)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function OptimizeRemoveDeadvars.guaranteed
refactored with the following changes:
- Use any() instead of for loop (
use-any
)
hex_str = "0" + hex_str | ||
hex_str = f"0{hex_str}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function bs_from_int
refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation
)
# sort by most used | ||
varmap = {} | ||
varnames = sorted(collector.vars.items(), key=lambda x: x[1], reverse=True) | ||
for i, (v, _) in enumerate(varnames): | ||
varmap[v] = bs_from_int(i) | ||
varmap = {v: bs_from_int(i) for i, (v, _) in enumerate(varnames)} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function OptimizeVarlen.visit_Module
refactored with the following changes:
- Move assignment closer to its usage within a block (
move-assign-in-block
) - Convert for loop into dictionary comprehension (
dict-comprehension
)
This removes the following comments ( why? ):
# sort by most used
a = Assign( | ||
return Assign( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function RewriteAugAssign.visit_AugAssign
refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
)
node.names[0].asname == None | ||
node.names[0].asname is None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function RewriteImport.visit_ImportFrom
refactored with the following changes:
- Use x is None rather than x == None (
none-compare
)
Branch
master
refactored by Sourcery.If you're happy with these changes, merge this Pull Request using the Squash and merge strategy.
See our documentation here.
Run Sourcery locally
Reduce the feedback loop during development by using the Sourcery editor plugin:
Review changes via command line
To manually merge these changes, make sure you're on the
master
branch, then run:Help us improve this pull request!