Skip to content

Commit b462904

Browse files
authored
Py source consistency using isort and pyupgrade tools, rm unused imports (#163)
Also remove unused shebangs on non-executable module and test files
1 parent 0ccdf1b commit b462904

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+66
-156
lines changed

docs/conf.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#!/usr/bin/env python
2-
# -*- coding: utf-8 -*-
32
#
43
# pymt documentation build configuration file, created by
54
# sphinx-quickstart on Fri Jun 9 13:47:02 2017.
@@ -25,7 +24,6 @@
2524

2625
import pymt
2726

28-
2927
if os.environ.get("READTHEDOCS", ""):
3028
# RTD doesn't use the repo's Makefile to build docs.
3129
import subprocess
@@ -69,9 +67,9 @@
6967
master_doc = "index"
7068

7169
# General information about the project.
72-
project = u"pymt"
73-
copyright = u"2018, Eric Hutton"
74-
author = u"Eric Hutton"
70+
project = "pymt"
71+
copyright = "2018, Eric Hutton"
72+
author = "Eric Hutton"
7573

7674
# The version info for the project you're documenting, acts as replacement
7775
# for |version| and |release|, also used in various other places throughout
@@ -147,15 +145,15 @@
147145
# (source start file, target name, title, author, documentclass
148146
# [howto, manual, or own class]).
149147
latex_documents = [
150-
(master_doc, "pymt.tex", u"pymt Documentation", u"Eric Hutton", "manual")
148+
(master_doc, "pymt.tex", "pymt Documentation", "Eric Hutton", "manual")
151149
]
152150

153151

154152
# -- Options for manual page output ------------------------------------
155153

156154
# One entry per manual page. List of tuples
157155
# (source start file, name, description, authors, manual section).
158-
man_pages = [(master_doc, "pymt", u"pymt Documentation", [author], 1)]
156+
man_pages = [(master_doc, "pymt", "pymt Documentation", [author], 1)]
159157

160158

161159
# -- Options for Texinfo output ----------------------------------------
@@ -167,7 +165,7 @@
167165
(
168166
master_doc,
169167
"pymt",
170-
u"pymt Documentation",
168+
"pymt Documentation",
171169
author,
172170
"pymt",
173171
"One line description of project.",

docs/scripts/make_table.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#! /usr/bin/env python
22
import os
33
import textwrap
4-
from tabulate import tabulate
54

65
import click
76
import yaml
7+
from tabulate import tabulate
88

99

1010
def construct_rows(notebook_index=None):
@@ -20,7 +20,7 @@ def construct_rows(notebook_index=None):
2020
[
2121
summary,
2222
"",
23-
"|binder-{0}|".format(name),
23+
f"|binder-{name}|",
2424
]
2525
)
2626
rows.append((name, summary))
@@ -59,12 +59,10 @@ def make_table(dest, notebook_index):
5959
footer = []
6060
for name, notebooks in index.items():
6161
footer.append(
62+
f"""
63+
.. |binder-{name}| image:: https://mybinder.org/badge_logo.svg
64+
:target: https://mybinder.org/v2/gh/csdms/pymt.git/master?filepath=notebooks%2F{notebooks[0]}
6265
"""
63-
.. |binder-{0}| image:: https://mybinder.org/badge_logo.svg
64-
:target: https://mybinder.org/v2/gh/csdms/pymt.git/master?filepath=notebooks%2F{1}
65-
""".format(
66-
name, notebooks[0]
67-
)
6866
)
6967
print(textwrap.dedent(os.linesep.join(footer)), file=dest)
7068

notebooks/conftest.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,15 @@
22

33
import pytest
44

5-
65
_TEST_DIR = pathlib.Path(__file__).absolute().parent
76

87

98
def collect_notebooks(src):
109
p = pathlib.Path(src)
1110
if p.is_dir():
12-
return set([_p.absolute() for _p in iter_notebooks_in_dir(p, src)])
11+
return {_p.absolute() for _p in iter_notebooks_in_dir(p, src)}
1312
else:
14-
raise ValueError("{0}: not a directory".format(src))
13+
raise ValueError(f"{src}: not a directory")
1514

1615

1716
def iter_notebooks_in_dir(path, root):

notebooks/test_notebooks.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66

77
_exclude_file = pathlib.Path(__file__).absolute().parent / "exclude.yml"
88
if _exclude_file.exists():
9-
with open(_exclude_file, "r") as fp:
10-
_EXCLUDE = dict([(item["file"], item["reason"]) for item in yaml.safe_load(fp)])
9+
with open(_exclude_file) as fp:
10+
_EXCLUDE = {item["file"]: item["reason"] for item in yaml.safe_load(fp)}
1111
else:
1212
_EXCLUDE = {}
1313

pymt/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
from ._version import __version__
2-
31
from gimli import UnitSystem
2+
3+
from ._version import __version__
44
from .model_collection import ModelCollection
55

66
MODELS = ModelCollection()

pymt/errors.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
#! /usr/bin/env python
2-
3-
41
class PymtError(Exception):
52

63
pass

pymt/framework/bmi_bridge.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,22 @@
44
import os
55
from pprint import pformat
66

7+
import gimli
78
import numpy as np
89
import yaml
9-
import gimli
1010

1111
from deprecated import deprecated
1212

13-
from ..utils import as_cwd
1413
from ..errors import BmiError
1514
from ..units import transform_azimuth_to_math, transform_math_to_azimuth
15+
from ..utils import as_cwd
1616
from .bmi_docstring import bmi_docstring
1717
from .bmi_mapper import GridMapperMixIn
1818
from .bmi_plot import quick_plot
1919
from .bmi_setup import SetupMixIn
2020
from .bmi_timeinterp import BmiTimeInterpolator
2121
from .bmi_ugrid import dataset_from_bmi_grid
2222

23-
2423
UNITS = gimli.units
2524

2625

pymt/framework/bmi_docstring.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
#! /usr/bin/env python
21
import jinja2
32
from landlab.core.messages import format_message
43
from model_metadata import MetadataNotFoundError, ModelMetadata
54

6-
75
# {{ desc|trim|wordwrap(70) if desc }}
86
_DOCSTRING = """
97
Basic Model Interface for {{ name }}.

pymt/framework/bmi_mapper.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#! /usr/bin/env python
21
import warnings
32

43
import numpy as np

pymt/framework/bmi_plot.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#! /usr/bin/env python
21
import matplotlib.pyplot as plt
32
import numpy as np
43

0 commit comments

Comments
 (0)