Skip to content
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

#263 refactor stylespy (Sourcery refactored) #272

Closed
wants to merge 1 commit into from

Conversation

sourcery-ai[bot]
Copy link
Contributor

@sourcery-ai sourcery-ai bot commented Nov 18, 2023

Pull Request #271 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 263-refactor-stylespy branch, then run:

git fetch origin sourcery/263-refactor-stylespy
git merge --ff-only FETCH_HEAD
git reset HEAD^

Help us improve this pull request!

WatermelonAI Summary

AI 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.
🍉🫶
Try us on VSCodium!

Copy link

what-the-diff bot commented Nov 18, 2023

PR Summary

  • Reworks type casting in DataType convert method
    The convert method, under the DataType class, has been altered. It now returns all values as strings, without any prior type casting.

  • Modifications in various property methods in fastkml/kml.py
    A set of properties in the 'kml.py' code file have been adjusted to prevent the return of null or non-existent values. These properties include style_url, author, snippet, address and phone_number.

  • Updates import syntax for urlparse
    Updates have been made on how urlparse is imported in the etree_element function within styles.py, specifically to urlparse.urlparse.

  • Alterations in get_style_by_url method
    In the KML class, the get_style_by_url method is altered to utilize a generator expression. It finds the style based on the specified URL with more efficiency now.

  • Conditional expression in strtobool function
    The strtobool function in styles.py uses a conditional expression instead of an if-else statement, optimizing the code.

  • Unnecessary type hints removed in StyleUrl class
    Extra type hints that turn out to be redundant in StyleUrl class have been successfully removed for cleaner code.

Copy link

codecov bot commented Nov 18, 2023

Codecov Report

Attention: 1 lines in your changes are missing coverage. Please review.

Comparison is base (9e3e4a9) 93.05% compared to head (d3f214a) 93.13%.

Files Patch % Lines
fastkml/enums.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@                    Coverage Diff                    @@
##           263-refactor-stylespy     #272      +/-   ##
=========================================================
+ Coverage                  93.05%   93.13%   +0.08%     
=========================================================
  Files                         34       34              
  Lines                       4865     4849      -16     
=========================================================
- Hits                        4527     4516      -11     
+ Misses                       338      333       -5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ghost
Copy link

ghost commented Nov 18, 2023

👇 Click on the image for a new way to code review

Review these changes using an interactive CodeSee Map

Legend

CodeSee Map legend

WatermelonAI Summary

AI 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.
🍉🫶
Have you starred Watermelon?

WatermelonAI Summary

AI 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.
🍉🫶
Try us on VSCode!

@@ -210,9 +210,7 @@ def style_url(self) -> Optional[str]:
Returns the url only, not a full StyleUrl object.

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 Summary

AI 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.
🍉🫶

return str(value)
return value
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function DataType.convert refactored with the following changes:

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
Copy link
Contributor Author

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:

Comment on lines -265 to +263
if self._atom_author:
return self._atom_author.name
return None
return self._atom_author.name if self._atom_author else None
Copy link
Contributor Author

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:

Comment on lines -303 to +299
text = self._snippet.get("text")
if text:
if text := self._snippet.get("text"):
Copy link
Contributor Author

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:

Comment on lines -342 to +337
if self._address:
return self._address
return None
return self._address if self._address else None
Copy link
Contributor Author

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:

Comment on lines -357 to +350
if self._phone_number:
return self._phone_number
return None
return self._phone_number if self._phone_number else None
Copy link
Contributor Author

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:

Comment on lines -1644 to +1635
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)
Copy link
Contributor Author

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)

Comment on lines -1714 to +1702
if self._geometry is not None:
return self._geometry.geometry
return None
return self._geometry.geometry if self._geometry is not None else None
Copy link
Contributor Author

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:

if val == "true":
return 1
return int(float(val))
return 1 if val == "true" else int(float(val))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function strtobool refactored with the following changes:

Base automatically changed from 263-refactor-stylespy to develop November 20, 2023 18:48
@sourcery-ai sourcery-ai bot closed this Nov 20, 2023
@sourcery-ai sourcery-ai bot deleted the sourcery/263-refactor-stylespy branch November 20, 2023 18:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

0 participants