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.4 #213

Merged
merged 32 commits into from
Jan 14, 2023
Merged

1.0.alpha.4 #213

merged 32 commits into from
Jan 14, 2023

Conversation

cleder
Copy link
Owner

@cleder cleder commented Jan 14, 2023

The great refactor of 2023

cleder and others added 28 commits December 7, 2022 20:03
Merge pull request #203 from cleder/develop
updates:
- [github.com/asottile/pyupgrade: v3.3.0 → v3.3.1](asottile/pyupgrade@v3.3.0...v3.3.1)
- [github.com/psf/black: 22.10.0 → 22.12.0](psf/black@22.10.0...22.12.0)
Bumps [actions/checkout](https://github.com/actions/checkout) from 3.1.0 to 3.2.0.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](actions/checkout@v3.1.0...v3.2.0)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
…/checkout-3.2.0

Bump actions/checkout from 3.1.0 to 3.2.0
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/pycqa/isort: 5.10.1 → v5.11.3](PyCQA/isort@5.10.1...v5.11.3)
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/pycqa/isort: v5.11.3 → 5.11.4](PyCQA/isort@v5.11.3...5.11.4)
[pre-commit.ci] pre-commit autoupdate
@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Jan 14, 2023

Sourcery Code Quality Report

✅  Merging this PR will increase code quality in the affected files by 1.46%.

Quality metrics Before After Change
Complexity 6.75 ⭐ 5.88 ⭐ -0.87 👍
Method Length 58.65 ⭐ 58.50 ⭐ -0.15 👍
Working memory 6.66 🙂 6.36 🙂 -0.30 👍
Quality 69.75% 🙂 71.21% 🙂 1.46% 👍
Other metrics Before After Change
Lines 2551 2878 327
Changed files Quality Before Quality After Quality Change
setup.py 94.13% ⭐ 94.11% ⭐ -0.02% 👎
fastkml/data.py 80.21% ⭐ 80.20% ⭐ -0.01% 👎
fastkml/enums.py 96.84% ⭐
fastkml/geometry.py 64.08% 🙂 64.08% 🙂 0.00%
fastkml/kml.py 68.52% 🙂 67.99% 🙂 -0.53% 👎
fastkml/mixins.py 81.58% ⭐
fastkml/times.py 69.47% 🙂 72.95% 🙂 3.48% 👍
fastkml/views.py 72.15% 🙂 70.79% 🙂 -1.36% 👎
tests/times_test.py 80.42% ⭐

Here are some functions in these files that still need a tune-up:

File Function Complexity Length Working Memory Quality Recommendation
fastkml/geometry.py Geometry._get_multigeometry 23 😞 285 ⛔ 11 😞 31.91% 😞 Refactor to reduce nesting. Try splitting into smaller methods. Extract out complex expressions
fastkml/kml.py _Feature.from_element 22 😞 517 ⛔ 8 🙂 35.14% 😞 Refactor to reduce nesting. Try splitting into smaller methods
fastkml/kml.py _Feature.etree_element 25 😞 431 ⛔ 7 🙂 36.15% 😞 Refactor to reduce nesting. Try splitting into smaller methods
fastkml/kml.py PhotoOverlay.from_element 23 😞 324 ⛔ 7 🙂 39.18% 😞 Refactor to reduce nesting. Try splitting into smaller methods
fastkml/views.py _AbstractView.etree_element 11 🙂 260 ⛔ 9 🙂 46.23% 😞 Try splitting into smaller methods

Legend and Explanation

The emojis denote the absolute quality of the code:

  • ⭐ excellent
  • 🙂 good
  • 😞 poor
  • ⛔ very poor

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!

@what-the-diff
Copy link

what-the-diff bot commented Jan 14, 2023

  • Update the code to work with Python 3.7+
  • Add support for custom data in KML files (see https://github.com/fastkml/fastkml/issues/84)
  • Added Enum class DateTimeResolution, which is used by TimeMixin and can be used elsewhere as well
  • Updated MANIFEST file so that tests are included when installing fastkml via pip install -e .[test] or similar commands
  • The TimeMixin class was added to mixins.py
  • A new KmlDateTime class was added to times.py, which is used by the other classes in that file
  • _TimePrimitive and its subclasses were updated with a few minor changes:
    • they now use the new KmlDateTime object instead of datetime objects directly (this allows for more flexibility)
    • some methods have been removed or renamed as part of this change (e.g., get_resolution() has been replaced by init())
  • Add TimeMixin to _AbstractView
  • Remove timespan and timestamp from AbstractView, add begin/end properties instead
  • Update pyproject.toml with Python 3.11 support (and remove the old unit test)
  • Move tests directory out of fastkml package into root dir for better discoverability by CI tools like GitHub Actions or TravisCI
  • Rename the test files to be in a tests folder
  • Remove unused imports and variables from styles_test.py
  • Added a new test file for the times classes.
  • Tested all possible date and time formats in KML files, including UTC dates/times with Z or +00:00 suffixes as well as local datetimes with offsets from GMT (e.g., -03:30).
  • Fixed bug where parsing of timestamps was not working correctly when using lxml parser instead of stdlib ElementTree parser; this is because lxml returns an empty string if there are no child elements to parse whereas ET returns None which caused problems downstream in fastkml codebase since it expected either a valid timestamp object or None but got "" instead so threw errors on trying to access attributes that don't exist on strings like .dt etc... This fix ensures that both parsers return the same thing now regardless whether they find any children under element tag or not -- i.e., always return None rather than "".
    4a) Also fixed issue where TimeSpan objects were being created even though only one end point was specified (i..e, begin OR end); previously would create TimeSpan object even if just had 1876-08-01, without corresponding . Now will throw error unless BOTH begin AND end tags present inside parent tags before creating Timespan instance variable within Document class instance variables dictionary (_features_dict).
    4b) Similarly also fixed issue whereby Timestamp instances were being created incorrectly by defaulting resolution attribute value to DateResolution enum type 'date' whenever neither start nor stop values provided for creation of Timestamp objeccts; now throws ValueError exception unless at least one value given between start and stop parameters passed into constructor method call upon instantiation of new Timestamp() object via kml module's factory function interface e..g, ts = kml._create_timestamp(start=None,stop="1997") --> raises ValueError("Timestamps must have either a beginning ('start')" ... )
  • Renamed fastkml/tests to tests
  • Changed the import statements in views_test.py from 'from fastkml' to 'from .base'. This is because we are now importing base relative to our current directory, which is no longer inside of a folder called "fastkml".
  • In test_create_camera(), changed datetime objects into KMLDateTime objects (which take datetimes as arguments). The reason for this change was that Camera() takes an argument of type times._KMLDateTimeBase and not just any old date time object; it needs something with more functionality than what's provided by Python's built-in datetime class alone.
  • Added assert lookat._timestamp... line in test create look at method so that the timestamp attribute can be accessed directly without having to go through getter methods first (since there isn't one)

@codecov
Copy link

codecov bot commented Jan 14, 2023

Codecov Report

Base: 92.42% // Head: 92.97% // Increases project coverage by +0.55% 🎉

Coverage data is based on head (09f0221) compared to base (8f10458).
Patch coverage: 98.48% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #213      +/-   ##
==========================================
+ Coverage   92.42%   92.97%   +0.55%     
==========================================
  Files          23       26       +3     
  Lines        4357     4414      +57     
==========================================
+ Hits         4027     4104      +77     
+ Misses        330      310      -20     
Impacted Files Coverage Δ
fastkml/geometry.py 94.65% <ø> (ø)
tests/base.py 100.00% <ø> (ø)
tests/config_test.py 93.33% <ø> (ø)
tests/oldunit_test.py 99.83% <ø> (ø)
fastkml/mixins.py 91.83% <91.83%> (ø)
fastkml/times.py 98.01% <96.29%> (-0.22%) ⬇️
fastkml/data.py 94.89% <100.00%> (+0.02%) ⬆️
fastkml/enums.py 100.00% <100.00%> (ø)
fastkml/kml.py 78.01% <100.00%> (-0.47%) ⬇️
fastkml/views.py 89.16% <100.00%> (+6.85%) ⬆️
... and 9 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@ghost
Copy link

ghost commented Jan 14, 2023

👇 Click on the image for a new way to code review
  • Make big changes easier — review code in small groups of related files

  • Know where to start — see the whole change at a glance

  • Take a code tour — explore the change with an interactive tour

  • Make comments and review — all fully sync’ed with github

    Try it now!

Review these changes using an interactive CodeSee Map

Legend

CodeSee Map Legend

@cleder cleder merged commit 20f5a6e into main Jan 14, 2023
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

1 participant