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

1.0 alpha 7 (Sourcery refactored) #278

Closed
wants to merge 1 commit into from
Closed

Conversation

sourcery-ai[bot]
Copy link
Contributor

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

Pull Request #277 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 develop branch, then run:

git fetch origin sourcery/develop
git merge --ff-only FETCH_HEAD
git reset HEAD^

Help us improve this pull request!

@sourcery-ai sourcery-ai bot requested a review from cleder November 21, 2023 11:47
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 -1720 to +1708
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:

year_month_day_match = year_month_day.match(datestr)
if year_month_day_match:
if year_month_day_match := year_month_day.match(datestr):
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 KmlDateTime.parse refactored with the following changes:

Comment on lines -229 to +235
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):
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 TimeSpan.etree_element refactored with the following changes:

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"))
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 TestStdLibrary.test_base_from_element_raises refactored with the following changes:

This removes the following comments ( why? ):

# type: ignore[attr-defined]

@@ -226,16 +225,14 @@ def etree_element(
) -> Element:
element = super().etree_element(precision=precision, verbosity=verbosity)
if self.begin is not None:
text = str(self.begin)
if text:
if text := str(self.begin):

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

@ghost
Copy link

ghost commented Nov 21, 2023

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

Review these changes using an interactive CodeSee Map

Legend

CodeSee Map legend

Copy link

what-the-diff bot commented Nov 21, 2023

PR Summary

  • Improvement of convert method in fastkml/enums.py
    The method now no longer explicitly casts to a string. This results in a cleaner and more efficient code.

  • Enhancements in fastkml/kml.py methods and properties
    Various property implementations have been improved to use conditional expressions instead of the classic "if" statement. This streamlines the code and enables quicker evaluations.

    • style_url property
    • author property
    • snippet property
    • address property
    • phone_number property
    • get_style_by_url method
  • Upgrade of strtobool function in fastkml/styles.py
    The strtobool function now uses a conditional expression instead of an "if" statement, yielding a clearer and more readable code.

  • Optimized methods in fastkml/times.py
    The method implementations utilize the walrus operator and conditional expressions, resulting in a reduced line count without diminishing code clarity.

    • parse class method
    • etree_element method
  • Refactoring of test_base_from_element_raises method in tests/base_test.py
    This test method now generates an Element object via the f-string syntax, which is more contemporary and performant than the old concatenation method.

Copy link

codecov bot commented Nov 21, 2023

Codecov Report

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

Comparison is base (2b2db5a) 93.05% compared to head (47d8109) 93.13%.

Files Patch % Lines
fastkml/enums.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #278      +/-   ##
===========================================
+ Coverage    93.05%   93.13%   +0.07%     
===========================================
  Files           33       33              
  Lines         4838     4819      -19     
===========================================
- Hits          4502     4488      -14     
+ Misses         336      331       -5     

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

@sourcery-ai sourcery-ai bot closed this Nov 21, 2023
@sourcery-ai sourcery-ai bot deleted the sourcery/develop branch November 21, 2023 11:49
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.

0 participants