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

Refactor geometry (Sourcery refactored) #241

Closed
wants to merge 1 commit into from

Conversation

sourcery-ai[bot]
Copy link
Contributor

@sourcery-ai sourcery-ai bot commented Oct 14, 2023

Pull Request #239 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 refactor-geometry branch, then run:

git fetch origin sourcery/refactor-geometry
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 October 14, 2023 17:53
@watermelon-copilot-for-code-review

@what-the-diff
Copy link

what-the-diff bot commented Oct 14, 2023

PR Summary

  • Simplification of the strtobool function in fastkml/styles.py
    The function now returns 1 when it receives the input "true", and converts other values into an integer after converting them to a float. This change streamlines the function and makes it more efficient.

  • Update to the ValueError condition in fastkml/styles.py
    The condition for raising a ValueError has been updated - it now also checks if the key in use is neither "highlight" nor "normal". This added condition makes error detection in the function more thorough and helps prevent incorrect key usage.

  • Removal of ValueError else case in fastkml/styles.py
    The unnecessary 'else' case that raised a ValueError has been removed. This makes the function cleaner and less cluttered.

  • Enhanced element variable assignment in tests/base_test.py
    The assignment process for the element variable has been updated to use an f-string instead of simple string concatenation. This not only simplifies the code, but also generally enhances performance.

@codecov
Copy link

codecov bot commented Oct 14, 2023

Codecov Report

All modified lines are covered by tests ✅

Comparison is base (7901627) 93.20% compared to head (fbee272) 93.24%.

Additional details and impacted files
@@                  Coverage Diff                  @@
##           refactor-geometry     #241      +/-   ##
=====================================================
+ Coverage              93.20%   93.24%   +0.03%     
=====================================================
  Files                     33       33              
  Lines                   5080     5076       -4     
=====================================================
- Hits                    4735     4733       -2     
+ Misses                   345      343       -2     
Files Coverage Δ
fastkml/styles.py 95.94% <100.00%> (+0.61%) ⬆️
tests/base_test.py 100.00% <100.00%> (ø)

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

@ghost
Copy link

ghost commented Oct 14, 2023

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

Review these changes using an interactive CodeSee Map

Legend

CodeSee Map legend

@watermelon-copilot-for-code-review

@watermelon-copilot-for-code-review

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 PolyStyle.from_element refactored with the following changes:

Comment on lines -631 to +629
if key is None:
if key is None or key.text not in ["highlight", "normal"]:
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 StyleMap.from_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]

Base automatically changed from refactor-geometry to develop October 14, 2023 18:27
@sourcery-ai sourcery-ai bot closed this Oct 14, 2023
@sourcery-ai sourcery-ai bot deleted the sourcery/refactor-geometry branch October 14, 2023 18:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

0 participants