Skip to content

Commit

Permalink
remove lint
Browse files Browse the repository at this point in the history
  • Loading branch information
mcflugen committed Jan 30, 2024
1 parent 4968d29 commit a3900cd
Show file tree
Hide file tree
Showing 30 changed files with 147 additions and 146 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ jobs:
if:
github.event_name == 'push' || github.event.pull_request.head.repo.full_name !=
github.repository

runs-on: ubuntu-latest

defaults:
run:
shell: bash -l {0}
Expand Down
3 changes: 2 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ repos:
rev: 5.13.2
hooks:
- id: isort
args: [--force-single-line-imports]

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
Expand All @@ -46,7 +47,7 @@ repos:
- id: forbid-new-submodules
- id: mixed-line-ending
- id: trailing-whitespace
- id: name-tests-test
# - id: name-tests-test
- id: file-contents-sorter
files: |
(?x)^(
Expand Down
1 change: 0 additions & 1 deletion LICENSE.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,3 @@ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.

15 changes: 6 additions & 9 deletions bmi_tester/__init__.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
from importlib.metadata import version
from bmi_tester._version import __version__
from bmi_tester.api import check_bmi
from bmi_tester.api import check_unit_is_dimensionless
from bmi_tester.api import check_unit_is_time
from bmi_tester.api import check_unit_is_valid

from .api import (
check_bmi,
check_unit_is_dimensionless,
check_unit_is_time,
check_unit_is_valid,
)

__version__ = version("bmi-tester")
__all__ = [
"__version__",
"check_bmi",
"check_unit_is_valid",
"check_unit_is_time",
Expand Down
1 change: 1 addition & 0 deletions bmi_tester/_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__version__ = "0.5.7.dev0"
6 changes: 2 additions & 4 deletions bmi_tester/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
import numpy as np
import pkg_resources
import pytest
import six


SECONDS = gimli.units.Unit("s")

Expand All @@ -29,8 +27,8 @@ def check_bmi(
os.environ["BMI_VERSION_STRING"] = bmi_version

if manifest:
if isinstance(manifest, six.string_types):
with open(manifest, "r") as fp:
if isinstance(manifest, str):
with open(manifest) as fp:
manifest = fp.read()
else:
manifest = os.linesep.join(manifest)
Expand Down
4 changes: 2 additions & 2 deletions bmi_tester/bmi.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import numpy as np


class Bmi(object):
class Bmi:
_input_var_names = ("land_surface__elevation", "land_surface_air__temperature")
_output_var_names = (
"land_surface__elevation",
Expand All @@ -22,7 +22,7 @@ def __init__(self):
}

def initialize(self, config_file):
with open(config_file, "r"):
with open(config_file):
pass

def update(self):
Expand Down
11 changes: 6 additions & 5 deletions bmi_tester/bmipytest.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
import click
import pkg_resources
from model_metadata import MetadataNotFoundError
from model_metadata.api import query, stage
from model_metadata.api import query
from model_metadata.api import stage
from pytest import ExitCode

from . import __version__
Expand All @@ -34,12 +35,12 @@ def validate_entry_point(ctx, param, value):
)
if not re.match(MODULE_REGEX, module_name):
raise click.BadParameter(
"Bad module name ({0})".format(module_name),
f"Bad module name ({module_name})",
param_hint="module_name:ClassName",
)
if not re.match(CLASS_REGEX, class_name):
raise click.BadParameter(
"Bad class name ({0})".format(class_name),
f"Bad class name ({class_name})",
param_hint="module_name:ClassName",
)
return value
Expand Down Expand Up @@ -79,7 +80,7 @@ def _tree(files):


@click.command(
context_settings=dict(ignore_unknown_options=True, allow_extra_args=True)
context_settings={"ignore_unknown_options": True, "allow_extra_args": True}
)
@click.version_option(version=__version__)
@click.option(
Expand Down Expand Up @@ -196,7 +197,7 @@ def main(
if manifest:
out(_tree(manifest))
out(f"> cat {stage_dir}/{config_file}")
with open(os.path.join(stage_dir, config_file), "r") as fp:
with open(os.path.join(stage_dir, config_file)) as fp:
out(fp.read())

with as_cwd(stage_dir):
Expand Down
6 changes: 3 additions & 3 deletions bmi_tester/bootstrap/test_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def load_component(entry_point):
else:
Bmi = load_component(class_to_test)

INPUT_FILE = os.environ.get("BMITEST_INPUT_FILE", None)
INPUT_FILE = os.environ.get("BMITEST_INPUT_FILE")


@pytest.mark.dependency()
Expand All @@ -51,7 +51,7 @@ def test_has_finalize():
)
def test_initialize(tmpdir):
"""Test component can initialize itself."""
infile = os.environ.get("BMITEST_INPUT_FILE", None)
infile = os.environ.get("BMITEST_INPUT_FILE")
manifest = os.environ.get("BMITEST_MANIFEST", infile or "").splitlines()

with tmpdir.as_cwd() as prev:
Expand All @@ -68,7 +68,7 @@ def test_initialize(tmpdir):
@pytest.mark.dependency(depends=["initialize_works"])
def test_update(tmpdir):
"""Test component can update itself."""
infile = os.environ.get("BMITEST_INPUT_FILE", None)
infile = os.environ.get("BMITEST_INPUT_FILE")
manifest = os.environ.get("BMITEST_MANIFEST", infile or "").splitlines()

with tmpdir.as_cwd() as prev:
Expand Down
2 changes: 1 addition & 1 deletion bmi_tester/data/udunits/README
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ The following units have been removed:
rem

The following units have been changed:
sievert
sievert
sverdrup

The following units have been added:
Expand Down
2 changes: 1 addition & 1 deletion bmi_tester/data/udunits/udunits2-accepted.xml
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ Units accepted for use with the SI
<def>cGy</def>
<aliases> <name><singular>rad</singular></name> </aliases>
</unit>
-->
-->
<!-- 'rem' is changed from 'cSv' since 'Sv' has been reassigned to sverdrup for CF
-->
<unit>
Expand Down
4 changes: 2 additions & 2 deletions bmi_tester/data/udunits/udunits2-base.xml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ SI base units.
2. When the mole is used, the elementary entities must be specified
and may be atoms, molecules, ions, electrons, other particles, or
specified groups of such particles.
specified groups of such particles.
-->
<base/>
<name><singular>mole</singular></name>
Expand All @@ -85,7 +85,7 @@ SI base units.
</unit>
<unit>
<!--
sdfsdfd
sdfsdfd
-->
<base/>
<name><singular>calendar_year</singular></name>
Expand Down
6 changes: 3 additions & 3 deletions bmi_tester/tests/stage_1/test_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def test_var_names(var_name):
if standard_names.is_valid_name(var_name):
standard_names.StandardName(var_name)
else:
warnings.warn("not a valid standard name: {name}".format(name=var_name))
warnings.warn(f"not a valid standard name: {var_name}", stacklevel=2)


@pytest.mark.dependency()
Expand Down Expand Up @@ -51,7 +51,7 @@ def test_get_input_var_names(initialized_bmi):
n_names = initialized_bmi.get_input_var_name_count()
assert len(names) == n_names
else:
warnings.warn("get_input_var_name_count not implemented")
warnings.warn("get_input_var_name_count not implemented", stacklevel=2)


@pytest.mark.dependency(depends=["test_output_var_name_count"])
Expand All @@ -64,4 +64,4 @@ def test_get_output_var_names(initialized_bmi):
n_names = initialized_bmi.get_output_var_name_count()
assert len(names) == n_names
else:
warnings.warn("get_output_var_name_count not implemented")
warnings.warn("get_output_var_name_count not implemented", stacklevel=2)
8 changes: 3 additions & 5 deletions bmi_tester/tests/stage_1/test_time.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@
import pytest
from pytest import approx

from bmi_tester.api import (
check_unit_is_dimensionless,
check_unit_is_time,
check_unit_is_valid,
)
from bmi_tester.api import check_unit_is_dimensionless
from bmi_tester.api import check_unit_is_time
from bmi_tester.api import check_unit_is_valid


@pytest.mark.dependency()
Expand Down
4 changes: 1 addition & 3 deletions bmi_tester/tests/stage_2/test_var.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,7 @@ def test_get_var_type(initialized_bmi, var_name):
try:
np.empty(1, dtype=dtype)
except TypeError:
raise AssertionError(
"get_var_type: bad data type name ({dtype})".format(dtype=dtype)
)
raise AssertionError(f"get_var_type: bad data type name ({dtype})")


def test_get_var_units(initialized_bmi, var_name):
Expand Down
24 changes: 12 additions & 12 deletions bmi_tester/tests/stage_3/test_grid.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from packaging.version import Version

import numpy as np
import pytest
from packaging.version import Version

from ..conftest import BMI_VERSION, skip_if_grid_type_is_not
from ..conftest import BMI_VERSION
from ..conftest import skip_if_grid_type_is_not

VALID_GRID_TYPES = (
"none",
Expand All @@ -20,7 +20,7 @@

# @pytest.mark.dependency()
def test_get_grid_rank(initialized_bmi, gid):
"Test grid rank for grid {gid}".format(gid=gid)
"Test grid rank for grid"
rank = initialized_bmi.get_grid_rank(gid)
assert isinstance(rank, int)
assert rank <= 3
Expand All @@ -29,15 +29,15 @@ def test_get_grid_rank(initialized_bmi, gid):


def test_get_grid_size(initialized_bmi, gid):
"Test grid size for grid {gid}".format(gid=gid)
"Test grid size for grid"
size = initialized_bmi.get_grid_size(gid)
assert isinstance(size, int)
assert size > 0


# @pytest.mark.dependency()
def test_get_grid_type(initialized_bmi, gid):
"Test grid is known for grid {gid}".format(gid=gid)
"Test grid is known for grid"
gtype = initialized_bmi.get_grid_type(gid)
assert isinstance(gtype, str)
assert gtype in VALID_GRID_TYPES
Expand All @@ -48,7 +48,7 @@ def test_get_grid_type(initialized_bmi, gid):
)
# @pytest.mark.dependency()
def test_get_grid_node_count(initialized_bmi, gid):
"Test number of nodes in grid {gid}".format(gid=gid)
"Test number of nodes in grid"
skip_if_grid_type_is_not(initialized_bmi, gid, "unstructured")

n_nodes = initialized_bmi.get_grid_node_count(gid)
Expand All @@ -58,7 +58,7 @@ def test_get_grid_node_count(initialized_bmi, gid):

# @pytest.mark.dependency()
def test_get_grid_edge_count(initialized_bmi, gid):
"Test number of edges in grid {gid}".format(gid=gid)
"Test number of edges in grid"
skip_if_grid_type_is_not(initialized_bmi, gid, "unstructured")

n_edges = initialized_bmi.get_grid_edge_count(gid)
Expand All @@ -70,7 +70,7 @@ def test_get_grid_edge_count(initialized_bmi, gid):

# @pytest.mark.dependency()
def test_get_grid_face_count(initialized_bmi, gid):
"Test number of faces in grid {gid}".format(gid=gid)
"Test number of faces in grid"
skip_if_grid_type_is_not(initialized_bmi, gid, "unstructured")

n_faces = initialized_bmi.get_grid_face_count(gid)
Expand All @@ -80,7 +80,7 @@ def test_get_grid_face_count(initialized_bmi, gid):

# @pytest.mark.dependency(depends=["test_get_grid_node_count", "test_get_grid_edge_count"])
def test_get_grid_edge_nodes(initialized_bmi, gid):
"Test nodes at edges for grid {gid}".format(gid=gid)
"Test nodes at edges for grid"
skip_if_grid_type_is_not(initialized_bmi, gid, "unstructured")

n_edges = initialized_bmi.get_grid_edge_count(gid)
Expand All @@ -100,7 +100,7 @@ def test_get_grid_edge_nodes(initialized_bmi, gid):
@pytest.mark.skip("edges_per_face")
# @pytest.mark.dependency(depends=["test_get_grid_node_count", "test_get_grid_edge_count", "test_get_grid_face_count"])
def test_get_grid_edges_per_face(initialized_bmi, gid):
"Test number of edges at each face for grid {gid}".format(gid=gid)
"Test number of edges at each face for grid"
skip_if_grid_type_is_not(initialized_bmi, gid, "unstructured")

n_edges = initialized_bmi.get_grid_edge_count(gid)
Expand All @@ -127,7 +127,7 @@ def test_get_grid_edges_per_face(initialized_bmi, gid):
]
)
def test_get_grid_face_edges(initialized_bmi, gid):
"Test edges at face for grid {gid}".format(gid=gid)
"Test edges at face for grid"
skip_if_grid_type_is_not(initialized_bmi, gid, "unstructured")

n_faces = initialized_bmi.get_grid_face_count(gid)
Expand Down
2 changes: 1 addition & 1 deletion bmi_tester/tests/stage_3/test_grid_uniform_rectilinear.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def test_get_grid_shape(initialized_bmi, gid):
try:
rtn = initialized_bmi.get_grid_shape(gid, shape)
except TypeError:
warnings.warn("get_grid_shape should take two arguments")
warnings.warn("get_grid_shape should take two arguments", stacklevel=2)
rtn = initialized_bmi.get_grid_shape(gid)
shape[:] = rtn
else:
Expand Down
7 changes: 4 additions & 3 deletions bmi_tester/tests/stage_3/test_value.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
from packaging.version import Version

import numpy as np
import pytest
from packaging.version import Version

from bmi_tester.api import empty_var_buffer

from ..conftest import BMI_VERSION_STRING, INPUT_FILE, Bmi
from ..conftest import BMI_VERSION_STRING
from ..conftest import INPUT_FILE
from ..conftest import Bmi

# from pytest_dependency import depends

Expand Down
1 change: 0 additions & 1 deletion docs/_templates/links.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@ <h3>Useful Links</h3>
<li><a href="https://github.com/csdms/bmi-tester/">bmi-tester @ GitHub</a></li>
<li><a href="https://github.com/csdms/bmi-tester/issues">Issue Tracker</a></li>
</ul>

1 change: 0 additions & 1 deletion docs/api/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,3 @@ Developer Documentation
:maxdepth: 2

modules

1 change: 0 additions & 1 deletion docs/authors.rst
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
.. include:: ../AUTHORS.rst

1 change: 0 additions & 1 deletion docs/changelog.rst
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
.. include:: ../CHANGES.rst

Loading

0 comments on commit a3900cd

Please sign in to comment.