-
Notifications
You must be signed in to change notification settings - Fork 92
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
Fix TimeStamp and TimeSpan class to use class_from_element method (Sourcery refactored) #267
Conversation
WatermelonAI SummaryAI Summary deactivated by sourcery-ai[bot] GitHub PRs
No results found in Jira Tickets :( No results found in Confluence Docs :( No results found in Slack Threads :( No results found in Notion Pages :( No results found in Linear Tickets :( No results found in Asana Tasks :( fastkml is an open repo and Watermelon will serve it for free. |
5cba575
to
5a911ff
Compare
PR Summary
|
WatermelonAI SummaryAI Summary deactivated by sourcery-ai[bot] GitHub PRs
No results found in Jira Tickets :( No results found in Confluence Docs :( No results found in Slack Threads :( No results found in Notion Pages :( No results found in Linear Tickets :( No results found in Asana Tasks :( fastkml is an open repo and Watermelon will serve it for free. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## 260-refactor-timestamp-and-timespan #267 +/- ##
=======================================================================
+ Coverage 92.83% 92.88% +0.05%
=======================================================================
Files 34 34
Lines 4812 4795 -17
=======================================================================
- Hits 4467 4454 -13
+ Misses 345 341 -4
☔ View full report in Codecov by Sentry. |
5a911ff
to
1e44f7c
Compare
@@ -206,9 +206,7 @@ def style_url(self) -> Optional[str]: | |||
Returns the url only, not a full StyleUrl object. | |||
if you need the full StyleUrl object use _style_url. | |||
""" | |||
if isinstance(self._style_url, StyleUrl): |
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.
This file contains at least one console log. Please remove any present.
WatermelonAI SummaryAI Summary deactivated by sourcery-ai[bot] GitHub PRs
No results found in Jira Tickets :( No results found in Confluence Docs :( No results found in Slack Threads :( No results found in Notion Pages :( No results found in Linear Tickets :( No results found in Asana Tasks :( fastkml is an open repo and Watermelon will serve it for free. |
if isinstance(self._style_url, StyleUrl): | ||
return self._style_url.url | ||
return None | ||
return self._style_url.url if isinstance(self._style_url, StyleUrl) 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 _Feature.style_url
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
)
if self._atom_author: | ||
return self._atom_author.name | ||
return None | ||
return self._atom_author.name if self._atom_author 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 _Feature.author
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
)
text = self._snippet.get("text") | ||
if text: | ||
if text := self._snippet.get("text"): |
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 _Feature.snippet
refactored with the following changes:
- Use named expression to simplify assignment and conditional (
use-named-expression
)
if self._address: | ||
return self._address | ||
return None | ||
return self._address if self._address 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 _Feature.address
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
)
if self._phone_number: | ||
return self._phone_number | ||
return None | ||
return self._phone_number if self._phone_number 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 _Feature.phone_number
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
)
for style in self.styles(): | ||
if style.id == id: | ||
return style | ||
return None | ||
return next((style for style in self.styles() if style.id == id), 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 Document.get_style_by_url
refactored with the following changes:
- Use the built-in function
next
instead of a for-loop (use-next
)
if self._geometry is not None: | ||
return self._geometry.geometry | ||
return None | ||
return self._geometry.geometry if self._geometry is not None 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 Placemark.geometry
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
)
year_month_day_match = year_month_day.match(datestr) | ||
if year_month_day_match: | ||
if year_month_day_match := year_month_day.match(datestr): |
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 KmlDateTime.parse
refactored with the following changes:
- Use named expression to simplify assignment and conditional (
use-named-expression
)
text = str(self.begin) | ||
if text: | ||
if text := str(self.begin): | ||
begin = config.etree.SubElement( # type: ignore[attr-defined] | ||
element, | ||
f"{self.ns}begin", | ||
) | ||
begin.text = text | ||
if self.end is not None: | ||
text = str(self.end) | ||
if text: | ||
if text := str(self.end): |
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 TimeSpan.etree_element
refactored with the following changes:
- Use named expression to simplify assignment and conditional [×2] (
use-named-expression
)
element = cast( | ||
types.Element, | ||
config.etree.Element(config.KMLNS + "Base"), # type: ignore[attr-defined] | ||
) | ||
element = cast(types.Element, config.etree.Element(f"{config.KMLNS}Base")) |
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 TestStdLibrary.test_base_from_element_raises
refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation
)
This removes the following comments ( why? ):
# type: ignore[attr-defined]
Pull Request #266 refactored by Sourcery.
If you're happy with these changes, merge this Pull Request using the Squash and merge strategy.
NOTE: As code is pushed to the original Pull Request, Sourcery will
re-run and update (force-push) this Pull Request with new refactorings as
necessary. If Sourcery finds no refactorings at any point, this Pull Request
will be closed automatically.
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
260-refactor-timestamp-and-timespan
branch, then run:Help us improve this pull request!