Skip to content

Commit dc508e1

Browse files
committed
Linting
1 parent 92ac6b8 commit dc508e1

File tree

12 files changed

+92
-80
lines changed

12 files changed

+92
-80
lines changed

domdf_python_tools/dates.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ def utc_timestamp_to_datetime(
179179
return new_datetime.astimezone(output_tz)
180180

181181

182-
if sys.version_info <= (3, 7):
182+
if sys.version_info <= (3, 7, 2):
183183
MonthsType = OrderedDict
184184
else:
185185
MonthsType = typing.OrderedDict[str, str]

domdf_python_tools/delegators.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ def _f(f: _C) -> _C:
121121
f.__signature__ = from_sig.replace( # type: ignore
122122
parameters=[
123123
from_params["self"],
124-
*to_sig.parameters.values()
124+
*to_sig.parameters.values(),
125125
]
126126
)
127127

domdf_python_tools/import_tools.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ def discover(
9696
.. versionchanged:: 1.0.0
9797
9898
Added the ``exclude_side_effects`` parameter.
99-
"""
99+
""" # noqa D400
100100

101101
matching_objects = []
102102

domdf_python_tools/pagesizes/units.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ def __call__(self, value: Union[SupportsFloat, str, bytes, bytearray] = 0.0) ->
293293

294294
class Unitpt(Unit):
295295
"""
296-
Point
296+
Point.
297297
"""
298298

299299
name = "pt"

domdf_python_tools/pretty_print.py

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -116,56 +116,57 @@ def _make_close(self, char: str, indent: int, obj):
116116
else:
117117
return char
118118

119-
def _pprint_dict(self, object, stream, indent, allowance, context, level):
119+
def _pprint_dict(self, object, stream, indent, allowance, context, level): # noqa: A002
120+
obj = object
120121
write = stream.write
121-
write(self._make_open('{', indent, object))
122+
write(self._make_open('{', indent, obj))
122123

123124
if self._indent_per_level > 1:
124125
write((self._indent_per_level - 1) * ' ')
125126

126-
if len(object):
127+
if len(obj):
127128
self._format_dict_items( # type: ignore
128-
object.items(),
129-
stream,
130-
indent,
131-
allowance + 1,
132-
context,
133-
level,
134-
)
129+
obj.items(),
130+
stream,
131+
indent,
132+
allowance + 1,
133+
context,
134+
level,
135+
)
135136

136-
write(self._make_close('}', indent, object))
137+
write(self._make_close('}', indent, obj))
137138

138139
_dispatch[dict.__repr__] = _pprint_dict
139140

140-
def _pprint_list(self, object, stream, indent, allowance, context, level):
141-
stream.write(self._make_open('[', indent, object))
142-
self._format_items(object, stream, indent, allowance + 1, context, level)
143-
stream.write(self._make_close(']', indent, object))
141+
def _pprint_list(self, obj, stream, indent, allowance, context, level):
142+
stream.write(self._make_open('[', indent, obj))
143+
self._format_items(obj, stream, indent, allowance + 1, context, level)
144+
stream.write(self._make_close(']', indent, obj))
144145

145146
_dispatch[list.__repr__] = _pprint_list
146147

147-
def _pprint_tuple(self, object, stream, indent, allowance, context, level):
148-
stream.write(self._make_open('(', indent, object))
149-
endchar = ",)" if len(object) == 1 else self._make_close(')', indent, object)
150-
self._format_items(object, stream, indent, allowance + len(endchar), context, level)
148+
def _pprint_tuple(self, obj, stream, indent, allowance, context, level):
149+
stream.write(self._make_open('(', indent, obj))
150+
endchar = ",)" if len(obj) == 1 else self._make_close(')', indent, obj)
151+
self._format_items(obj, stream, indent, allowance + len(endchar), context, level)
151152
stream.write(endchar)
152153

153154
_dispatch[tuple.__repr__] = _pprint_tuple
154155

155-
def _pprint_set(self, object, stream, indent, allowance, context, level):
156-
if not len(object):
157-
stream.write(repr(object))
156+
def _pprint_set(self, obj, stream, indent, allowance, context, level):
157+
if not len(obj):
158+
stream.write(repr(obj))
158159
return
159-
typ = object.__class__
160+
typ = obj.__class__
160161
if typ is set:
161-
stream.write(self._make_open('{', indent, object))
162-
endchar = self._make_close('}', indent, object)
162+
stream.write(self._make_open('{', indent, obj))
163+
endchar = self._make_close('}', indent, obj)
163164
else:
164165
stream.write(typ.__name__ + f"({{\n{' ' * (indent + self._indent_per_level + len(typ.__name__) + 1)}")
165166
endchar = f",\n{' ' * (indent + self._indent_per_level + len(typ.__name__) + 1)}}})"
166167
indent += len(typ.__name__) + 1
167-
object = sorted(object, key=_safe_key)
168-
self._format_items(object, stream, indent, allowance + len(endchar), context, level)
168+
obj = sorted(obj, key=_safe_key)
169+
self._format_items(obj, stream, indent, allowance + len(endchar), context, level)
169170
stream.write(endchar)
170171

171172
_dispatch[set.__repr__] = _pprint_set
@@ -215,7 +216,7 @@ def _format_attribute_items(self, items, stream, indent, allowance, context, lev
215216

216217
write = stream.write
217218
indent += self._indent_per_level
218-
delimnl = ',\n' + ' ' * indent
219+
delimnl = ",\n" + ' ' * indent
219220
last_index = len(items) - 1
220221

221222
for i, (key, ent) in enumerate(items):

domdf_python_tools/stringlist.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,15 +72,15 @@ def size(self) -> int:
7272
def size(self, size: int) -> None:
7373
self._size = int(size)
7474

75-
@property
76-
def type(self) -> str: # noqa A002,A003 # pylint: disable=redefined-builtin
75+
@property # noqa: A002,A003
76+
def type(self) -> str: # noqa: A002,A003 # pylint: disable=redefined-builtin
7777
"""
7878
The indent character.
7979
"""
8080

8181
return self._type
8282

83-
@type.setter # noqa A002 # pylint: disable=redefined-builtin
83+
@type.setter # noqa: A002,A003 # pylint: disable=redefined-builtin
8484
def type(self, type: str) -> None: # noqa A002 # pylint: disable=redefined-builtin
8585
if not str(type):
8686
raise ValueError("'type' cannot an empty string.")

domdf_python_tools/testing.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -343,10 +343,9 @@ def only_pypy(reason: str = "Only required on PyPy.") -> _pytest.mark.structures
343343
return pytest.mark.skipif(condition=not PYPY, reason=reason)
344344

345345

346-
@pytest.fixture(scope="function")
346+
@pytest.fixture()
347347
def tmp_pathplus(tmp_path: Path) -> PathPlus:
348348
"""
349-
350349
Pytest fixture that returns a temporary directory in the form of a
351350
:class:`~domdf_python_tools.paths.PathPlus` object.
352351
@@ -365,6 +364,6 @@ def my_test(tmp_pathplus: PathPlus):
365364
:rtype:
366365
367366
.. versionadded:: 0.10.0
368-
"""
367+
""" # noqa: D400
369368

370369
return PathPlus(tmp_path)

domdf_python_tools/typing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ def dumps(
121121
**kwds: Any,
122122
) -> str:
123123
"""
124-
Serialize ``obj`` to a JSON formatted ``str``.
124+
Serialize ``obj`` to a JSON formatted :class:`str`.
125125
126126
:param obj:
127127
:param skipkeys:

domdf_python_tools/utils.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ def head(obj: Union[Tuple, List, "DataFrame", "Series", String, HasHead], n: int
465465
return repr(obj)
466466
else:
467467
head_of_namedtuple = {k: v for k, v in zip(obj._fields[:n], obj[:n])} # type: ignore
468-
repr_fmt = '(' + ', '.join(f"{k}={v!r}" for k, v in head_of_namedtuple.items()) + f", {etc})"
468+
repr_fmt = '(' + ", ".join(f"{k}={v!r}" for k, v in head_of_namedtuple.items()) + f", {etc})"
469469
return obj.__class__.__name__ + repr_fmt
470470

471471
elif isinstance(obj, (list, tuple)):
@@ -569,10 +569,10 @@ def deprecated(
569569
deprecated_in: Optional[str] = None,
570570
removed_in: Optional[str] = None,
571571
current_version: Optional[str] = None,
572-
details: str = "",
572+
details: str = '',
573573
name: Optional[str] = None
574574
):
575-
r"""Decorate a function to signify its deprecation
575+
r"""Decorate a function to signify its deprecation.
576576
577577
This function wraps a method that will soon be removed and does two things:
578578
@@ -657,7 +657,7 @@ def deprecated(
657657

658658
def _function_wrapper(function):
659659
# Everything *should* have a docstring, but just in case...
660-
existing_docstring = function.__doc__ or ""
660+
existing_docstring = function.__doc__ or ''
661661

662662
# split docstring at first occurrence of newline
663663
string_list = existing_docstring.split("\n", 1)
@@ -726,7 +726,7 @@ def _inner(*args, **kwargs):
726726

727727
return function(*args, **kwargs)
728728

729-
_inner.__doc__ = "".join(string_list)
729+
_inner.__doc__ = ''.join(string_list)
730730

731731
return _inner
732732

tests/list_tests.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def test_reversed(self):
102102
assert list(reversed(self.type2test())) == self.type2test()
103103
# Bug 3689: make sure list-reversed-iterator doesn't have __len__
104104
with pytest.raises(TypeError):
105-
len(reversed([1, 2, 3]))
105+
len(reversed([1, 2, 3])) # type: ignore
106106

107107
def test_setitem(self):
108108
a = self.type2test([0, 1])

0 commit comments

Comments
 (0)