Skip to content

Commit 6fc24ad

Browse files
committed
remove lint
1 parent 0067d48 commit 6fc24ad

File tree

16 files changed

+68
-74
lines changed

16 files changed

+68
-74
lines changed

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1818
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1919
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2020
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21-
SOFTWARE.
21+
SOFTWARE.

docs/source/conf.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
#
32
# standard_names documentation build configuration file, created by
43
# sphinx-quickstart on Fri Jul 22 11:31:51 2016.
@@ -12,9 +11,8 @@
1211
# All configuration values have a default; values that are commented out
1312
# serve to show the default.
1413

15-
import sys
1614
import os
17-
import shlex
15+
import sys
1816

1917
sys.path.insert(
2018
0, os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir, os.pardir))
@@ -217,14 +215,14 @@
217215
# -- Options for LaTeX output ---------------------------------------------
218216

219217
latex_elements = {
220-
# The paper size ('letterpaper' or 'a4paper').
221-
#'papersize': 'letterpaper',
222-
# The font size ('10pt', '11pt' or '12pt').
223-
#'pointsize': '10pt',
224-
# Additional stuff for the LaTeX preamble.
225-
#'preamble': '',
226-
# Latex figure (float) alignment
227-
#'figure_align': 'htbp',
218+
# The paper size ('letterpaper' or 'a4paper').
219+
# 'papersize': 'letterpaper',
220+
# The font size ('10pt', '11pt' or '12pt').
221+
# 'pointsize': '10pt',
222+
# Additional stuff for the LaTeX preamble.
223+
# 'preamble': '',
224+
# Latex figure (float) alignment
225+
# 'figure_align': 'htbp',
228226
}
229227

230228
# Grouping the document tree into LaTeX files. List of tuples

docs/source/index.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,4 +109,3 @@ Indices and tables
109109
* :ref:`genindex`
110110
* :ref:`modindex`
111111
* :ref:`search`
112-

standard_names/__init__.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
"""The CSDMS Standard Names"""
22
from importlib.metadata import version
33

4-
from .error import BadNameError, BadRegistryError
4+
from .error import BadNameError
5+
from .error import BadRegistryError
56
from .registry import NamesRegistry
6-
from .standardname import StandardName, is_valid_name
7+
from .standardname import StandardName
8+
from .standardname import is_valid_name
79

810
__version__ = version("standard-names")
911
__all__ = [

standard_names/cmd/snbuild.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
snbuild data/models.yaml data/scraped.yaml \
55
> standard_names/data/standard_names.yaml
66
"""
7-
from __future__ import print_function
87

98
import os
109

@@ -31,7 +30,7 @@ def snbuild(file, newline=None):
3130
--------
3231
>>> from __future__ import print_function
3332
>>> import os
34-
>>> from six.moves import StringIO
33+
>>> from io import StringIO
3534
>>> import standard_names as csn
3635
3736
>>> lines = os.linesep.join(['air__temperature', 'water__temperature'])

standard_names/cmd/sndump.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
Example usage:
44
sndump -n -o -q -op --format=wiki > standard_names.wiki
55
"""
6-
from __future__ import print_function
76

87
import argparse
98
import os
@@ -34,7 +33,7 @@ def sndump(file=None, format="plain", sorted=True, keys=None, newline=None):
3433
--------
3534
>>> from __future__ import print_function
3635
>>> import os
37-
>>> from six.moves import StringIO
36+
>>> from io import StringIO
3837
>>> import standard_names as csn
3938
4039
>>> lines = os.linesep.join(['air__temperature', 'water__temperature'])
@@ -72,10 +71,10 @@ class CustomAction(argparse.Action):
7271

7372
def __call__(self, parser, namespace, values, option_string=None):
7473
if "ordered_args" not in namespace:
75-
setattr(namespace, "ordered_args", [])
74+
namespace.ordered_args = []
7675
previous = namespace.ordered_args
7776
previous.append(self.dest)
78-
setattr(namespace, "ordered_args", previous)
77+
namespace.ordered_args = previous
7978

8079

8180
def main(args=None):

standard_names/cmd/snscrape.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@
66
http://csdms.colorado.edu/wiki/CSN_Operation_Templates \
77
> data/scraped.yaml
88
"""
9-
from __future__ import print_function
109

1110
import os
1211

13-
from ..utilities import FORMATTERS, SCRAPERS, scrape
12+
from ..utilities import FORMATTERS
13+
from ..utilities import SCRAPERS
14+
from ..utilities import scrape
1415

1516
_AS_TXT = FORMATTERS["txt"]
1617

@@ -41,7 +42,7 @@ def snscrape(files, with_headers=False, regex=None, format="url", newline=None):
4142
Examples
4243
--------
4344
>>> from __future__ import print_function
44-
>>> from six.moves import StringIO
45+
>>> from io import StringIO
4546
>>> import standard_names as csn
4647
4748
>>> file1 = StringIO(\"\"\"

standard_names/cmd/snsql.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#! /usr/bin/env python
2-
from __future__ import print_function
32

43
import os
54

standard_names/cmd/snvalidate.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#! /usr/bin/env python
22
"""Validate a list of names."""
3-
from __future__ import print_function
43

54
import argparse
65
import os

standard_names/error.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class BadNameError(Error):
1313
"""Error to indicate a poorly-formed standard name."""
1414

1515
def __init__(self, name):
16-
super(BadNameError, self).__init__()
16+
super().__init__()
1717
self._name = name
1818

1919
def __str__(self):
@@ -29,7 +29,7 @@ class BadRegistryError(Error):
2929
"""Error to indicate a bad NamesRegistry."""
3030

3131
def __init__(self, names):
32-
super(BadRegistryError, self).__init__()
32+
super().__init__()
3333
self._names = tuple(sorted(names))
3434

3535
def __str__(self):

standard_names/registry.py

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
#! /usr/bin/env python
21
import os
32
import warnings
43
from glob import glob
54

6-
from six import string_types
7-
8-
from .error import BadNameError, BadRegistryError
5+
from .error import BadNameError
6+
from .error import BadRegistryError
97
from .standardname import StandardName
108

119

@@ -27,7 +25,7 @@ def load_names_from_txt(file_like, onerror="raise"):
2725
2826
Examples
2927
--------
30-
>>> from six.moves import StringIO
28+
>>> from io import StringIO
3129
>>> import standard_names as csn
3230
>>> names = StringIO(\"\"\"
3331
... air__temperature
@@ -55,20 +53,21 @@ def load_names_from_txt(file_like, onerror="raise"):
5553
if bad_names:
5654
if onerror == "warn":
5755
for name in bad_names:
58-
warnings.warn("{name}: not a valid name".format(name=name))
56+
warnings.warn(f"{name}: not a valid name", stacklevel=2)
5957
elif onerror == "raise":
6058
raise BadRegistryError(bad_names)
6159

6260
return names
6361

6462

6563
def _strict_version_or_raise(version_str):
66-
from packaging.version import InvalidVersion, Version
64+
from packaging.version import InvalidVersion
65+
from packaging.version import Version
6766

6867
try:
6968
return Version(version_str)
70-
except InvalidVersion:
71-
raise ValueError("{version}: Not a version string".format(version=version_str))
69+
except InvalidVersion as error:
70+
raise ValueError(f"{version_str}: Not a version string") from error
7271

7372

7473
def _get_latest_names_file(path=None, prefix="names-", suffix=".txt"):
@@ -108,7 +107,7 @@ def _get_latest_names_file(path=None, prefix="names-", suffix=".txt"):
108107
"""
109108
data_dir = path or os.path.join(os.path.dirname(__file__), "data")
110109

111-
name_glob = "{prefix}*{suffix}".format(prefix=prefix, suffix=suffix)
110+
name_glob = f"{prefix}*{suffix}"
112111
data_file_pattern = os.path.join(data_dir, name_glob)
113112
files = [os.path.basename(file_) for file_ in glob(data_file_pattern)]
114113

@@ -136,7 +135,7 @@ def _get_latest_names_file(path=None, prefix="names-", suffix=".txt"):
136135
return None, None
137136

138137

139-
class NamesRegistry(object):
138+
class NamesRegistry:
140139

141140
"""A registry of CSDMS Standard Names.
142141
@@ -221,7 +220,7 @@ def __init__(self, *args, **kwds):
221220
if paths is None:
222221
paths = []
223222

224-
if isinstance(paths, string_types) or hasattr(paths, "readline"):
223+
if isinstance(paths, str) or hasattr(paths, "readline"):
225224
paths = [paths]
226225

227226
self._names = set()
@@ -232,8 +231,8 @@ def __init__(self, *args, **kwds):
232231
self._version = version or "0.0.0"
233232

234233
for path in paths:
235-
if isinstance(path, string_types):
236-
with open(path, "r") as fp:
234+
if isinstance(path, str):
235+
with open(path) as fp:
237236
self._load(fp)
238237
else:
239238
self._load(path)
@@ -339,8 +338,7 @@ def __len__(self):
339338
return len(self._names)
340339

341340
def __iter__(self):
342-
for name in self._names:
343-
yield name
341+
yield from self._names
344342

345343
def search(self, name):
346344
"""Search the registry for a name.
@@ -395,7 +393,7 @@ def names_with(self, parts):
395393
tuple of str
396394
Names from the registry that contains the given words.
397395
"""
398-
if isinstance(parts, string_types):
396+
if isinstance(parts, str):
399397
parts = (parts,)
400398

401399
remaining_names = self._names

standard_names/standardname.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
"""A CSDMS standard name."""
33
import re
44

5-
from six import string_types
6-
75
from .error import BadNameError
86

97
_PREFIX_REGEX = "^[a-z]([a-zA-Z0-9~-]|_(?!_))*"
@@ -28,7 +26,7 @@ def is_valid_name(name):
2826
return bool(STANDARD_NAME_REGEX.match(name))
2927

3028

31-
class StandardName(object):
29+
class StandardName:
3230

3331
"""A CSDMS standard name.
3432
@@ -111,8 +109,8 @@ def decompose_name(name):
111109
"""
112110
try:
113111
(object_part, quantity_clause) = name.split("__")
114-
except ValueError:
115-
raise BadNameError(name)
112+
except ValueError as error:
113+
raise BadNameError(name) from error
116114

117115
(operators, quantity_part) = StandardName.decompose_quantity(quantity_clause)
118116

@@ -214,7 +212,7 @@ def operators(self):
214212

215213
@operators.setter
216214
def operators(self, value):
217-
if isinstance(value, string_types):
215+
if isinstance(value, str):
218216
value = (value,)
219217
self._operators = value
220218
self._name = StandardName.compose_name(

standard_names/utilities/__init__.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
1-
from .decorators import format_as_wiki, format_as_yaml, google_doc, plain_text, url
2-
from .io import FORMATTERS, SCRAPERS, from_list_file, from_model_file, scrape
1+
from .decorators import format_as_wiki
2+
from .decorators import format_as_yaml
3+
from .decorators import google_doc
4+
from .decorators import plain_text
5+
from .decorators import url
6+
from .io import FORMATTERS
7+
from .io import SCRAPERS
8+
from .io import from_list_file
9+
from .io import from_model_file
10+
from .io import scrape
311

412
__all__ = [
513
"format_as_wiki",

standard_names/utilities/decorators.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33

44
import os
55

6-
from six import string_types
7-
86

97
def format_as_wiki(func):
108
"""
@@ -52,7 +50,7 @@ def _wrapped(lines, **kwds):
5250

5351
if heading:
5452
pre = "=" * heading_level
55-
wiki_lines.insert(0, "%s %s %s" % (pre, heading.title(), pre))
53+
wiki_lines.insert(0, f"{pre} {heading.title()} {pre}")
5654

5755
return newline.join(wiki_lines)
5856

@@ -114,7 +112,7 @@ def _wrapped(lines, **kwds):
114112
items = [line for line in lines if line]
115113
if items:
116114
for line in items:
117-
yaml_lines.append("%s- %s" % (" " * indent, line))
115+
yaml_lines.append("{}- {}".format(" " * indent, line))
118116
else:
119117
yaml_lines.append("%s[]" % (" " * indent))
120118

@@ -176,8 +174,8 @@ def _wrapped(name, **kwds):
176174
name : str
177175
Name of the file as a string.
178176
"""
179-
if isinstance(name, string_types):
180-
with open(name, "r") as file_like:
177+
if isinstance(name, str):
178+
with open(name) as file_like:
181179
rtn = func(file_like, **kwds)
182180
else:
183181
rtn = func(name, **kwds)
@@ -233,7 +231,7 @@ def _wrapped(name, **kwds):
233231
except subprocess.CalledProcessError:
234232
raise
235233
else:
236-
with open(tfile, "r") as file_like:
234+
with open(tfile) as file_like:
237235
rtn = func(file_like, **kwds)
238236
finally:
239237
os.remove(tfile)

0 commit comments

Comments
 (0)