-
Notifications
You must be signed in to change notification settings - Fork 0
Sourcery refactored main branch #1
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
base: main
Are you sure you want to change the base?
Conversation
if self.doi: | ||
return self.doi | ||
return self._label() | ||
return self.doi or self._label() |
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 Article.label
refactored with the following changes:
- Lift code into else after jump in control flow (
reintroduce-else
) - Replace if statement with if expression (
assign-if-exp
) - Simplify if expression by using or (
or-if-exp-identity
)
if not self.doi: | ||
return {self.label, self._label(lower_p=True)} | ||
return { | ||
self.doi, | ||
self.label, | ||
self._label(exclude_doi=True), | ||
self._label(lower_p=True), | ||
self._label(exclude_doi=True, lower_p=True), | ||
} | ||
return ( | ||
{ | ||
self.doi, | ||
self.label, | ||
self._label(exclude_doi=True), | ||
self._label(lower_p=True), | ||
self._label(exclude_doi=True, lower_p=True), | ||
} | ||
if self.doi | ||
else {self.label, self._label(lower_p=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 Article.labels
refactored with the following changes:
- Lift code into else after jump in control flow (
reintroduce-else
) - Replace if statement with if expression (
assign-if-exp
) - Swap if/else branches of if expression to remove negation (
swap-if-expression
)
{ | ||
{} | ||
if simplified | ||
else { | ||
"references": self.references, | ||
"extra": self.extra, | ||
"sources": list(self.sources), | ||
} | ||
if not simplified | ||
else {} |
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 Article.to_dict
refactored with the following changes:
- Swap if/else branches of if expression to remove negation (
swap-if-expression
)
format or dumps them in the `output`. | ||
""" | ||
if not len(sources) > 0: | ||
if len(sources) <= 0: |
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 citation_pairs
refactored with the following changes:
- Simplify logical expression using De Morgan identities (
de-morgan
)
format or dumps them in the `output`. | ||
""" | ||
if not len(sources) > 0: | ||
if len(sources) <= 0: |
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 to_json
refactored with the following changes:
- Simplify logical expression using De Morgan identities (
de-morgan
)
raw_dict.setdefault("CR", []) | ||
for key, seq in raw_dict.items(): | ||
processed_data.update(parse(key, seq)) | ||
processed_data |= parse(key, seq) |
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 parse_all
refactored with the following changes:
- Merge dictionary updates via the union operator (
dict-assign-update-to-union
)
if not raw: | ||
return None | ||
return " ".join(raw) | ||
return " ".join(raw) if raw else 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 _joined
refactored with the following changes:
- Lift code into else after jump in control flow (
reintroduce-else
) - Replace if statement with if expression (
assign-if-exp
) - Swap if/else branches of if expression to remove negation (
swap-if-expression
)
data.update(page.groupdict()) | ||
data |= page.groupdict() |
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 _find_volume_info
refactored with the following changes:
- Merge dictionary updates via the union operator (
dict-assign-update-to-union
)
else None, | ||
"journal": None | ||
if journal.isspace() | ||
else journal.strip().replace(".", "").upper(), |
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 _scopus_ref_to_isi
refactored with the following changes:
- Swap if/else branches of if expression to remove negation (
swap-if-expression
)
article = parse_record(item.strip()) | ||
yield article | ||
yield parse_record(item.strip()) |
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 parse_file
refactored with the following changes:
- Inline variable that is immediately yielded (
inline-immediately-yielded-variable
)
Sourcery Code Quality Report❌ Merging this PR will decrease code quality in the affected files by 0.70%.
Here are some functions in these files that still need a tune-up:
Legend and ExplanationThe emojis denote the absolute quality of the code:
The 👍 and 👎 indicate whether the quality has improved or gotten worse with this pull request. 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! Help us improve this quality report! |
Branch
main
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
main
branch, then run:Help us improve this pull request!