-
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
refs = set([r.strip() for r in refnames.strip("()").split(",")]) | ||
refs = {r.strip() for r in refnames.strip("()").split(",")} | ||
# starting in git-1.8.3, tags are listed as "tag: foo-1.0" instead of | ||
# just "foo-1.0". If we see a "tag: " prefix, prefer those. | ||
TAG = "tag: " | ||
tags = set([r[len(TAG):] for r in refs if r.startswith(TAG)]) | ||
tags = {r[len(TAG):] for r in refs if r.startswith(TAG)} |
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 git_versions_from_keywords
refactored with the following changes:
- Replace unneeded comprehension with generator (
comprehension-to-generator
) - Replace list(), dict() or set() with comprehension (
collection-builtin-to-comprehension
)
if line.strip().startswith(versionfile_source): | ||
if "export-subst" in line.strip().split()[1:]: | ||
present = True | ||
if ( | ||
line.strip().startswith(versionfile_source) | ||
and "export-subst" in line.strip().split()[1:] | ||
): | ||
present = True |
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 do_vcs_install
refactored with the following changes:
- Merge nested if conditions (
merge-nested-ifs
)
for i in range(3): | ||
for _ in range(3): |
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 versions_from_parentdir
refactored with the following changes:
- Replace unused for index with underscore (
for-index-underscore
)
if pieces["dirty"]: | ||
rendered += ".dirty" | ||
else: | ||
# exception #1 | ||
rendered = "0+untagged.%d.g%s" % (pieces["distance"], | ||
pieces["short"]) | ||
if pieces["dirty"]: | ||
rendered += ".dirty" | ||
if pieces["dirty"]: | ||
rendered += ".dirty" |
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 render_pep440
refactored with the following changes:
- Hoist conditional out of nested conditional (
hoist-if-from-if
) - Hoist repeated code outside conditional statement (
hoist-statement-from-if
)
if pieces["dirty"]: | ||
rendered += ".dev0" | ||
else: | ||
# exception #1 | ||
rendered = "0.post%d" % pieces["distance"] | ||
if pieces["dirty"]: | ||
rendered += ".dev0" | ||
if pieces["dirty"]: | ||
rendered += ".dev0" |
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 render_pep440_old
refactored with the following changes:
- Hoist conditional out of nested conditional (
hoist-if-from-if
) - Hoist repeated code outside conditional statement (
hoist-statement-from-if
)
if pieces["dirty"]: | ||
rendered += ".dev0" | ||
else: | ||
# exception #1 | ||
rendered = "0.post%d" % pieces["distance"] | ||
if pieces["dirty"]: | ||
rendered += ".dev0" | ||
if pieces["dirty"]: | ||
rendered += ".dev0" |
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 render_pep440_old
refactored with the following changes:
- Hoist conditional out of nested conditional (
hoist-if-from-if
) - Hoist repeated code outside conditional statement (
hoist-statement-from-if
)
msg = self.msg.format(**self.kwargs) | ||
return msg | ||
return self.msg.format(**self.kwargs) |
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 ZiplineCalendarError.__str__
refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
)
if direction == "next": | ||
if self._minute_to_session_label_cache[0] == dt: | ||
return self._minute_to_session_label_cache[1] | ||
if direction == "next" and self._minute_to_session_label_cache[0] == dt: | ||
return self._minute_to_session_label_cache[1] |
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 TradingCalendar.minute_to_session_label
refactored with the following changes:
- Merge nested if conditions (
merge-nested-ifs
)
if dt.weekday() == SUNDAY or dt.weekday() == MONDAY: | ||
if dt.weekday() in [SUNDAY, MONDAY]: |
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 songkran_festival_last_day_observance
refactored with the following changes:
- Replace multiple comparisons of same variable with
in
operator (merge-comparisons
)
for h in holidays: | ||
if dt in h.dates(dt - one_day, dt + one_day) or \ | ||
dt.weekday() in WEEKENDS: | ||
return True | ||
|
||
return False | ||
return any(dt in h.dates(dt - one_day, dt + one_day) or \ | ||
dt.weekday() in WEEKENDS for h in holidays) |
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 is_holiday_or_weekend
refactored with the following changes:
- Use any() instead of for loop (
use-any
)
Sourcery Code Quality Report (beta)✅ Merging this PR will increase code quality in the affected files by 0.02 out of 10.
Here are some functions in these files that still need a tune-up:
Please see our documentation here for details on how these metrics are calculated. We are actively working on this report - lots more documentation and extra metrics to come! |
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: