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

Fix datetime imports #2787

Merged
merged 6 commits into from
Jun 4, 2024
Merged

Fix datetime imports #2787

merged 6 commits into from
Jun 4, 2024

Conversation

pnuu
Copy link
Member

@pnuu pnuu commented Apr 22, 2024

In many places, we have used from datetime import datetime. This is bad, since it masks the module for further imports:

from datetime import datetime
from datetime.timezone import utc

Sorting these the other way around will cause complaints from flake8/ruff.

This PR changes all of these import to import datetime as dt, so we need on the single import to access other items:

import datetime as dt

dt.datetime(1980, 3, 19)
dt.timedelta(minutes=42)
now = dt.datetime.now(dt.timezone.utc)

This is a change that makes implementing the timezone aware datetimes of #2752 easier.

  • Closes #xxxx
  • Tests added
  • Fully documented
  • Add your name to AUTHORS.md if not there already

@pnuu pnuu added enhancement code enhancements, features, improvements refactor labels Apr 22, 2024
@pnuu pnuu self-assigned this Apr 22, 2024
Copy link

codecov bot commented Apr 22, 2024

Codecov Report

Attention: Patch coverage is 95.48611% with 26 lines in your changes missing coverage. Please review.

Project coverage is 95.94%. Comparing base (aeb3391) to head (3b5e62c).
Report is 507 commits behind head on main.

Files with missing lines Patch % Lines
satpy/writers/awips_tiled.py 33.33% 4 Missing ⚠️
satpy/readers/aapp_l1b.py 60.00% 2 Missing ⚠️
satpy/readers/amsr2_l2_gaasp.py 33.33% 2 Missing ⚠️
satpy/readers/ghrsst_l3c_sst.py 0.00% 2 Missing ⚠️
satpy/readers/scatsat1_l2b.py 33.33% 2 Missing ⚠️
satpy/readers/seviri_l1b_icare.py 60.00% 2 Missing ⚠️
satpy/readers/vii_base_nc.py 60.00% 2 Missing ⚠️
satpy/tests/features/steps/steps-load.py 0.00% 2 Missing ⚠️
satpy/readers/caliop_l2_cloud.py 50.00% 1 Missing ⚠️
satpy/readers/hrit_jma.py 80.00% 1 Missing ⚠️
... and 6 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2787      +/-   ##
==========================================
+ Coverage   94.57%   95.94%   +1.37%     
==========================================
  Files         379      379              
  Lines       53886    53842      -44     
==========================================
+ Hits        50964    51661     +697     
+ Misses       2922     2181     -741     
Flag Coverage Δ
behaviourtests 4.09% <1.38%> (+<0.01%) ⬆️
unittests 96.04% <95.81%> (+0.87%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

@coveralls
Copy link

Pull Request Test Coverage Report for Build 8783919300

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 0.0%

Totals Coverage Status
Change from base Build 8781051256: 0.0%
Covered Lines: 0
Relevant Lines: 0

💛 - Coveralls

Copy link
Member

@sfinkens sfinkens left a comment

Choose a reason for hiding this comment

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

Oh, nasty... Thanks for fixing this!

Variables previously named dt are now called date. I think this might be misleading in some cases. Sometimes it's a date, sometimes a timestamp with more precision, sometimes an offset or a timedelta. Obviously the previous name wasn't any better, so feel free to ignore this if takes too much time :)

Copy link
Member

@sfinkens sfinkens left a comment

Choose a reason for hiding this comment

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

Thanks for all the hard work!

@mraspaud mraspaud merged commit 4a9ed62 into pytroll:main Jun 4, 2024
16 of 19 checks passed
@mraspaud mraspaud added this to the v0.49.0 milestone Jun 4, 2024
@pnuu pnuu deleted the fix-datetime-imports branch September 10, 2024 12:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement code enhancements, features, improvements refactor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants