satpy icon indicating copy to clipboard operation
satpy copied to clipboard

Fix datetime imports

Open pnuu opened this issue 1 year ago • 2 comments

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 https://github.com/pytroll/satpy/issues/2752 easier.

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

pnuu avatar Apr 22 '24 12:04 pnuu

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 :warning:
satpy/readers/aapp_l1b.py 60.00% 2 Missing :warning:
satpy/readers/amsr2_l2_gaasp.py 33.33% 2 Missing :warning:
satpy/readers/ghrsst_l3c_sst.py 0.00% 2 Missing :warning:
satpy/readers/scatsat1_l2b.py 33.33% 2 Missing :warning:
satpy/readers/seviri_l1b_icare.py 60.00% 2 Missing :warning:
satpy/readers/vii_base_nc.py 60.00% 2 Missing :warning:
satpy/tests/features/steps/steps-load.py 0.00% 2 Missing :warning:
satpy/readers/caliop_l2_cloud.py 50.00% 1 Missing :warning:
satpy/readers/hrit_jma.py 80.00% 1 Missing :warning:
... 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%) :arrow_up:
unittests 96.04% <95.81%> (+0.87%) :arrow_up:

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

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Apr 22 '24 12:04 codecov[bot]

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

coveralls avatar Apr 22 '24 12:04 coveralls