Skip to content

Commit

Permalink
Drop unused importlib syntax for python 3.8
Browse files Browse the repository at this point in the history
  • Loading branch information
xylar committed Oct 20, 2023
1 parent 052014c commit 69333ff
Show file tree
Hide file tree
Showing 14 changed files with 14 additions and 47 deletions.
2 changes: 1 addition & 1 deletion polaris/cache.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import argparse
import importlib.resources as imp_res
import json
import os
import pickle
Expand All @@ -9,7 +10,6 @@

from polaris import Step
from polaris.config import PolarisConfigParser
from polaris.io import imp_res


def update_cache(step_paths, date_string=None, dry_run=False):
Expand Down
3 changes: 1 addition & 2 deletions polaris/component.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import importlib.resources as imp_res
import json

from polaris.io import imp_res


class Component:
"""
Expand Down
8 changes: 0 additions & 8 deletions polaris/io.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
import os
import sys
import tempfile
from typing import TYPE_CHECKING # noqa: F401
from urllib.parse import urlparse

if TYPE_CHECKING or sys.version_info >= (3, 9, 0):
import importlib.resources as imp_res # noqa: F401
else:
# python <= 3.8
import importlib_resources as imp_res # noqa: F401

import progressbar
import requests

Expand Down
3 changes: 1 addition & 2 deletions polaris/job/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import importlib.resources as imp_res
import os

import numpy as np
from jinja2 import Template

from polaris.io import imp_res


def write_job_script(config, machine, target_cores, min_cores, work_dir,
suite=''):
Expand Down
2 changes: 1 addition & 1 deletion polaris/list.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import argparse
import importlib.resources as imp_res
import os
import re
import sys

from polaris.components import get_components
from polaris.io import imp_res


def list_cases(task_expr=None, number=None, verbose=False):
Expand Down
8 changes: 1 addition & 7 deletions polaris/machines/__init__.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
import importlib.resources as imp_res
import os
import socket
import sys
from typing import TYPE_CHECKING # noqa: F401

if TYPE_CHECKING or sys.version_info >= (3, 9, 0):
import importlib.resources as imp_res # noqa: F401
else:
# python <= 3.8
import importlib_resources as imp_res # noqa: F401

from mache import discover_machine as mache_discover_machine

Expand Down
3 changes: 1 addition & 2 deletions polaris/namelist.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import importlib.resources as imp_res
from typing import Dict

from polaris.io import imp_res


def parse_replacements(package, namelist):
"""
Expand Down
3 changes: 1 addition & 2 deletions polaris/ocean/vertical/grid_1d.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import importlib.resources as imp_res
import json

import numpy
import numpy as np
from netCDF4 import Dataset
from scipy.optimize import root_scalar

from polaris.io import imp_res


def generate_1d_grid(config):
"""
Expand Down
9 changes: 1 addition & 8 deletions polaris/seaice/tasks/single_column/standard_physics/viz.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
import sys
from typing import TYPE_CHECKING # noqa: F401

if TYPE_CHECKING or sys.version_info >= (3, 9, 0):
import importlib.resources as imp_res # noqa: F401
else:
# python <= 3.8
import importlib_resources as imp_res # noqa: F401
import importlib.resources as imp_res

import matplotlib.pyplot as plt
import xarray as xr
Expand Down
3 changes: 2 additions & 1 deletion polaris/step.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import grp
import importlib.resources as imp_res
import logging
import os
import shutil
Expand All @@ -8,7 +9,7 @@
from mache import MachineInfo

from polaris.config import PolarisConfigParser
from polaris.io import download, imp_res, symlink
from polaris.io import download, symlink
from polaris.validate import compare_variables


Expand Down
3 changes: 1 addition & 2 deletions polaris/streams.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import importlib.resources as imp_res
from copy import deepcopy

from jinja2 import Template
from lxml import etree

from polaris.io import imp_res


def read(package, streams_filename, tree=None, replacements=None):
"""
Expand Down
2 changes: 1 addition & 1 deletion polaris/suite.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import argparse
import importlib.resources as imp_res
import sys
from typing import List

from polaris.io import imp_res
from polaris.setup import setup_tasks


Expand Down
9 changes: 1 addition & 8 deletions polaris/viz/style.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
import sys
from typing import TYPE_CHECKING # noqa: F401

if TYPE_CHECKING or sys.version_info >= (3, 9, 0):
import importlib.resources as imp_res # noqa: F401
else:
# python <= 3.8
import importlib_resources as imp_res # noqa: F401
import importlib.resources as imp_res

import matplotlib.pyplot as plt

Expand Down
3 changes: 1 addition & 2 deletions polaris/yaml.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import argparse
import importlib.resources as imp_res
from collections import OrderedDict
from typing import Dict

from jinja2 import Template
from lxml import etree
from ruamel.yaml import YAML

from polaris.io import imp_res


class PolarisYaml:
"""
Expand Down

0 comments on commit 69333ff

Please sign in to comment.