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

IP-241 - Use ruff to enforce import ordering. #5

Merged
merged 2 commits into from
Apr 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@

# Black code formatting of entire repository
da4cd7af618fea30ab54052f6ccaa137c5471d82

# ruff import ordering for entire repository
78e1c643990cbe21c584ac3374e79d2139ae2277
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ repos:
rev: v0.3.4
hooks:
- id: ruff
args: ["--fix", "--show-fixes"]
args: ["--fix", "--show-fixes", "--select", "I"]
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 24.3.0
hooks:
Expand Down
2 changes: 1 addition & 1 deletion bin/project_local_granule.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@
from os import environ
from unittest.mock import patch

from harmony.util import config
from harmony.message import Message
from harmony.util import config

from swath_projector.adapter import SwathProjectorAdapter

Expand Down
2 changes: 1 addition & 1 deletion swath_projector/adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from harmony import BaseHarmonyAdapter
from harmony.message import Source as HarmonySource
from harmony.util import download, generate_output_filename, HarmonyException, stage
from harmony.util import HarmonyException, download, generate_output_filename, stage
from pystac import Asset, Item

from swath_projector.reproject import reproject
Expand Down
4 changes: 2 additions & 2 deletions swath_projector/interpolation.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@
"""

import os
from functools import partial
from logging import Logger
from typing import Dict, List, Optional, Tuple
import os

import numpy as np
from netCDF4 import Dataset
from pyresample.bilinear import get_bil_info, get_sample_from_bil_info
from pyresample.ewa import fornav, ll2cr
from pyresample.geometry import AreaDefinition, SwathDefinition
from pyresample.kd_tree import get_neighbour_info, get_sample_from_neighbour_info
from pyresample.utils import check_and_wrap
from varinfo import VarInfoFromNetCDF4
import numpy as np

from swath_projector.nc_single_band import HARMONY_TARGET, write_single_band_output
from swath_projector.swath_geometry import (
Expand Down
6 changes: 3 additions & 3 deletions swath_projector/nc_merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
attributes.
"""

from datetime import datetime, timezone
from typing import Dict, Optional, Set, Tuple, Union
import json
import logging
import os
from datetime import datetime, timezone
from typing import Dict, Optional, Set, Tuple, Union

import numpy as np
from netCDF4 import Dataset, Variable
from varinfo import VarInfoFromNetCDF4
import numpy as np

from swath_projector.exceptions import MissingReprojectedDataError
from swath_projector.utilities import get_variable_file_path, variable_in_dataset
Expand Down
5 changes: 2 additions & 3 deletions swath_projector/nc_single_band.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,9 @@

from typing import Dict, Tuple

from pyresample.geometry import AreaDefinition
from netCDF4 import Dataset
import numpy as np

from netCDF4 import Dataset
from pyresample.geometry import AreaDefinition

DIMENSION_METADATA = {
'lat': {
Expand Down
5 changes: 2 additions & 3 deletions swath_projector/reproject.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
""" Data Services Swath Projector service for Harmony """

from tempfile import mkdtemp
from typing import Dict
import functools
import logging
import os
from tempfile import mkdtemp
from typing import Dict

from harmony.message import Message
from pyproj import Proj
Expand All @@ -13,7 +13,6 @@
from swath_projector import nc_merge
from swath_projector.interpolation import resample_all_variables


RADIUS_EARTH_METRES = (
6_378_137 # http://nssdc.gsfc.nasa.gov/planetary/factsheet/earthfact.html
)
Expand Down
4 changes: 2 additions & 2 deletions swath_projector/swath_geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
"""

from typing import List, Tuple
import functools
from typing import List, Tuple

import numpy as np
from netCDF4 import Variable
from pyproj import Proj
import numpy as np


def get_projected_resolution(
Expand Down
4 changes: 2 additions & 2 deletions swath_projector/utilities.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from typing import Dict, Optional, Tuple, Union
import os
from typing import Dict, Optional, Tuple, Union

import numpy as np
from netCDF4 import Dataset, Variable
from varinfo import VariableFromNetCDF4
import numpy as np

from swath_projector.exceptions import MissingCoordinatesError

Expand Down
4 changes: 2 additions & 2 deletions tests/test_pyresample_reproject.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from unittest import TestCase
from unittest.mock import patch, ANY
from unittest.mock import ANY, patch

from harmony.message import Message
from harmony.util import config

from swath_projector.adapter import SwathProjectorAdapter
from tests.test_utils import download_side_effect, StringContains
from tests.test_utils import StringContains, download_side_effect


@patch('swath_projector.adapter.stage', return_value='https://example.com/data')
Expand Down
9 changes: 4 additions & 5 deletions tests/test_swath_projector.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
import json
from datetime import datetime
from os import makedirs
from shutil import copy, rmtree
from unittest import TestCase
from unittest.mock import Mock, patch, ANY
import json

from netCDF4 import Dataset
from unittest.mock import ANY, Mock, patch

from harmony.message import Message
from harmony.util import config
from netCDF4 import Dataset

from swath_projector.adapter import SwathProjectorAdapter
from tests.test_utils import download_side_effect, StringContains
from tests.test_utils import StringContains, download_side_effect


@patch('swath_projector.nc_merge.datetime')
Expand Down
6 changes: 3 additions & 3 deletions tests/unit/test_interpolation.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@
from unittest import TestCase
from unittest.mock import MagicMock, patch

import numpy as np
from netCDF4 import Dataset
from pyproj import Proj
from pyresample.geometry import AreaDefinition
import numpy as np
from varinfo import VarInfoFromNetCDF4

from swath_projector.interpolation import (
check_for_valid_interpolation,
EPSILON,
RADIUS_OF_INFLUENCE,
check_for_valid_interpolation,
get_parameters_tuple,
get_reprojection_cache,
get_swath_definition,
get_target_area,
resample_all_variables,
resample_variable,
RADIUS_OF_INFLUENCE,
)
from swath_projector.nc_single_band import HARMONY_TARGET
from swath_projector.reproject import CF_CONFIG_FILE
Expand Down
6 changes: 3 additions & 3 deletions tests/unit/test_nc_merge.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from datetime import datetime
from unittest import TestCase
from unittest.mock import Mock, patch
import json
import logging
import os
from datetime import datetime
from unittest import TestCase
from unittest.mock import Mock, patch

from netCDF4 import Dataset
from varinfo import VarInfoFromNetCDF4
Expand Down
6 changes: 3 additions & 3 deletions tests/unit/test_nc_single_band.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@
from unittest import TestCase
from unittest.mock import Mock

import numpy as np
from netCDF4 import Dataset
from pyproj.crs import CRS
from pyresample.geometry import AreaDefinition
import numpy as np

from swath_projector.nc_single_band import (
write_dimensions,
HARMONY_TARGET,
write_dimension_variables,
write_dimensions,
write_grid_mapping,
write_science_variable,
write_single_band_output,
HARMONY_TARGET,
)


Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_swath_geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
from unittest import TestCase
from uuid import uuid4

import numpy as np
from netCDF4 import Dataset
from pyproj import Proj
import numpy as np

from swath_projector.swath_geometry import (
clockwise_point_sort,
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/test_utilities.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
from unittest import TestCase
from unittest.mock import Mock

import numpy as np
from netCDF4 import Dataset, Variable
from varinfo import VarInfoFromNetCDF4
import numpy as np

from swath_projector.exceptions import MissingCoordinatesError
from swath_projector.utilities import (
construct_absolute_path,
create_coordinates_key,
get_variable_values,
get_coordinate_variable,
get_scale_and_offset,
get_variable_file_path,
get_variable_numeric_fill_value,
get_variable_values,
make_array_two_dimensional,
qualify_reference,
variable_in_dataset,
Expand Down
Loading