pytroll / satpy

Python package for earth-observing satellite data processing
http://satpy.readthedocs.org/en/latest/
GNU General Public License v3.0
1.06k stars 292 forks source link

Fix datetime imports #2787

Closed pnuu closed 3 months ago

pnuu commented 5 months ago

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.

codecov[bot] commented 5 months ago

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 ```diff @@ 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](https://app.codecov.io/gh/pytroll/satpy/pull/2787/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pytroll) | Coverage Δ | | |---|---|---| | [behaviourtests](https://app.codecov.io/gh/pytroll/satpy/pull/2787/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pytroll) | `4.09% <1.38%> (+<0.01%)` | :arrow_up: | | [unittests](https://app.codecov.io/gh/pytroll/satpy/pull/2787/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pytroll) | `96.04% <95.81%> (+0.87%)` | :arrow_up: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pytroll#carryforward-flags-in-the-pull-request-comment) to find out more.

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

coveralls commented 5 months ago

Pull Request Test Coverage Report for Build 8783919300

Details


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

💛 - Coveralls