From 247c770ceed1e66fc48a8a8649a910448bd7cbd3 Mon Sep 17 00:00:00 2001 From: Martin Raspaud Date: Wed, 28 Aug 2024 13:12:56 +0200 Subject: [PATCH] Revert "Ruff fix" This reverts commit 52ae086aa3e9d6b2ea988aaff6149bd850a2e65f. --- .pre-commit-config.yaml | 10 +++++----- doc/source/conf.py | 1 + pygac/__init__.py | 1 - pygac/configuration.py | 1 - pygac/correct_tsm_issue.py | 5 ++--- pygac/gac_io.py | 2 +- pygac/gac_pod.py | 2 +- pygac/gac_reader.py | 2 ++ pygac/klm_reader.py | 1 - pygac/lac_pod.py | 2 +- pygac/lac_reader.py | 2 ++ pygac/pygac_geotiepoints.py | 1 + pygac/runner.py | 3 ++- pygac/tests/test_angles.py | 3 ++- pygac/tests/test_io.py | 2 -- pygac/tests/test_pod.py | 6 ++---- pygac/tests/test_slerp.py | 4 +--- pygac/tests/test_tsm.py | 3 +-- pygac/tests/test_utils.py | 2 +- pygac/utils.py | 7 ++++--- 20 files changed, 29 insertions(+), 31 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4071a67..efc390e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -2,12 +2,12 @@ exclude: '^$' fail_fast: false repos: - - repo: https://github.com/astral-sh/ruff-pre-commit + #- repo: https://github.com/astral-sh/ruff-pre-commit # Ruff version. - rev: 'v0.3.2' - hooks: - - id: ruff - args: [--fix] + #rev: 'v0.3.2' + #hooks: + #- id: ruff + #args: [--fix] - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.5.0 hooks: diff --git a/doc/source/conf.py b/doc/source/conf.py index 0d065c6..e069084 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -11,6 +11,7 @@ # All configuration values have a default; values that are commented out # serve to show the default. +import sys, os # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the diff --git a/pygac/__init__.py b/pygac/__init__.py index 0a984b2..8d07330 100644 --- a/pygac/__init__.py +++ b/pygac/__init__.py @@ -30,7 +30,6 @@ "install').") import logging - from pygac.configuration import get_config, read_config_file # noqa from pygac.runner import get_reader_class, process_file # noqa diff --git a/pygac/configuration.py b/pygac/configuration.py index f808d3e..4ceb7ee 100644 --- a/pygac/configuration.py +++ b/pygac/configuration.py @@ -27,7 +27,6 @@ import logging import os import sys - try: import configparser except ImportError: diff --git a/pygac/correct_tsm_issue.py b/pygac/correct_tsm_issue.py index 394a215..12ea602 100644 --- a/pygac/correct_tsm_issue.py +++ b/pygac/correct_tsm_issue.py @@ -23,10 +23,9 @@ an orbit contain corrupt data. This module identifies affected pixels and flags them with fill values.""" -import datetime - -import bottleneck as bn import numpy as np +import bottleneck as bn +import datetime TSM_AFFECTED_INTERVALS_POD = { 3: [(datetime.datetime(2001, 10, 19, 4, 50), datetime.datetime(2001, 10, 19, 13, 38)), diff --git a/pygac/gac_io.py b/pygac/gac_io.py index 69110bc..5c2311d 100644 --- a/pygac/gac_io.py +++ b/pygac/gac_io.py @@ -33,7 +33,7 @@ import h5py import numpy as np -from pygac.utils import check_user_scanlines, slice_channel, strip_invalid_lat +from pygac.utils import slice_channel, strip_invalid_lat, check_user_scanlines LOG = logging.getLogger(__name__) diff --git a/pygac/gac_pod.py b/pygac/gac_pod.py index bc81416..380014c 100644 --- a/pygac/gac_pod.py +++ b/pygac/gac_pod.py @@ -30,8 +30,8 @@ import numpy as np -from pygac.gac_reader import GACReader from pygac.pod_reader import PODReader, main_pod +from pygac.gac_reader import GACReader LOG = logging.getLogger(__name__) diff --git a/pygac/gac_reader.py b/pygac/gac_reader.py index 52ec6cd..ecf3efe 100644 --- a/pygac/gac_reader.py +++ b/pygac/gac_reader.py @@ -31,6 +31,8 @@ import pygac.pygac_geotiepoints as gtp from pygac.pygac_geotiepoints import GAC_LONLAT_SAMPLE_POINTS from pygac.reader import Reader, ReaderError +import pygac.pygac_geotiepoints as gtp + LOG = logging.getLogger(__name__) diff --git a/pygac/klm_reader.py b/pygac/klm_reader.py index 0655b8b..db840a8 100644 --- a/pygac/klm_reader.py +++ b/pygac/klm_reader.py @@ -36,7 +36,6 @@ import datetime import logging - try: from enum import IntFlag except ImportError: diff --git a/pygac/lac_pod.py b/pygac/lac_pod.py index 8d84dd9..3ecffbf 100644 --- a/pygac/lac_pod.py +++ b/pygac/lac_pod.py @@ -28,8 +28,8 @@ import numpy as np -from pygac.lac_reader import LACReader from pygac.pod_reader import PODReader, main_pod +from pygac.lac_reader import LACReader LOG = logging.getLogger(__name__) diff --git a/pygac/lac_reader.py b/pygac/lac_reader.py index 2cb046b..dd18293 100644 --- a/pygac/lac_reader.py +++ b/pygac/lac_reader.py @@ -29,6 +29,8 @@ import pygac.pygac_geotiepoints as gtp from pygac.pygac_geotiepoints import LAC_LONLAT_SAMPLE_POINTS from pygac.reader import Reader, ReaderError +import pygac.pygac_geotiepoints as gtp + LOG = logging.getLogger(__name__) diff --git a/pygac/pygac_geotiepoints.py b/pygac/pygac_geotiepoints.py index ed41c60..18d35cc 100644 --- a/pygac/pygac_geotiepoints.py +++ b/pygac/pygac_geotiepoints.py @@ -25,6 +25,7 @@ import geotiepoints as gtp + import numpy as np GAC_LONLAT_SAMPLE_POINTS = np.arange(4, 405, 8) diff --git a/pygac/runner.py b/pygac/runner.py index 1029810..78e1d4d 100644 --- a/pygac/runner.py +++ b/pygac/runner.py @@ -31,12 +31,13 @@ class for a given file. import logging import os -from pygac.configuration import get_config from pygac.gac_klm import GACKLMReader from pygac.gac_pod import GACPODReader from pygac.lac_klm import LACKLMReader from pygac.lac_pod import LACPODReader from pygac.utils import file_opener +from pygac.configuration import get_config + LOG = logging.getLogger(__name__) diff --git a/pygac/tests/test_angles.py b/pygac/tests/test_angles.py index e3be986..97b5e6b 100644 --- a/pygac/tests/test_angles.py +++ b/pygac/tests/test_angles.py @@ -28,7 +28,8 @@ import numpy as np -from pygac.utils import centered_modulus, get_absolute_azimuth_angle_diff +from pygac.utils import (get_absolute_azimuth_angle_diff, + centered_modulus) class TestAngles(unittest.TestCase): diff --git a/pygac/tests/test_io.py b/pygac/tests/test_io.py index 2bb57fb..c859c74 100644 --- a/pygac/tests/test_io.py +++ b/pygac/tests/test_io.py @@ -20,14 +20,12 @@ """Test the I/O.""" import unittest - try: import mock except ImportError: from unittest import mock import numpy as np import numpy.testing - import pygac.gac_io as gac_io import pygac.utils as utils diff --git a/pygac/tests/test_pod.py b/pygac/tests/test_pod.py index 373ba2d..f9d89a4 100644 --- a/pygac/tests/test_pod.py +++ b/pygac/tests/test_pod.py @@ -21,21 +21,19 @@ """Test module for the pod reading.""" import datetime as dt -import sys import unittest - import numpy as np import numpy.testing - +import sys try: from unittest import mock except ImportError: import mock from pygac.clock_offsets_converter import txt as clock_offsets_txt +from pygac.reader import ReaderError, NoTLEData from pygac.gac_pod import GACPODReader from pygac.lac_pod import LACPODReader -from pygac.reader import NoTLEData, ReaderError from pygac.tests.utils import CalledWithArray diff --git a/pygac/tests/test_slerp.py b/pygac/tests/test_slerp.py index f48201f..f225631 100644 --- a/pygac/tests/test_slerp.py +++ b/pygac/tests/test_slerp.py @@ -25,10 +25,8 @@ import unittest - -import numpy as np - from pygac.slerp import slerp +import numpy as np class TestSlerp(unittest.TestCase): diff --git a/pygac/tests/test_tsm.py b/pygac/tests/test_tsm.py index 45d3fe8..5a21d10 100644 --- a/pygac/tests/test_tsm.py +++ b/pygac/tests/test_tsm.py @@ -21,12 +21,11 @@ """Test TSM module.""" import unittest +import pygac.correct_tsm_issue as tsm import numpy as np import numpy.testing -import pygac.correct_tsm_issue as tsm - class TSMTest(unittest.TestCase): """Test TSM module.""" diff --git a/pygac/tests/test_utils.py b/pygac/tests/test_utils.py index 5fcf411..65f3a9b 100644 --- a/pygac/tests/test_utils.py +++ b/pygac/tests/test_utils.py @@ -31,7 +31,7 @@ import numpy as np -from pygac.utils import calculate_sun_earth_distance_correction, file_opener +from pygac.utils import file_opener, calculate_sun_earth_distance_correction class TestUtils(unittest.TestCase): diff --git a/pygac/utils.py b/pygac/utils.py index e35b564..1473d0b 100644 --- a/pygac/utils.py +++ b/pygac/utils.py @@ -22,6 +22,7 @@ import gzip import io import logging + from contextlib import contextmanager, nullcontext import numpy as np @@ -198,9 +199,9 @@ def _slice(ch, start_line, end_line, update=None): ch_slc = ch[start_line:end_line + 1, :].copy() if update: - updated = [_update_scanline(line, start_line, end_line) - if line is not None else None - for line in update] + updated = [_update_scanline(l, start_line, end_line) + if l is not None else None + for l in update] return ch_slc, updated return ch_slc