Skip to content

Commit 2931272

Browse files
committed
Linting
1 parent 21ec888 commit 2931272

File tree

13 files changed

+53
-50
lines changed

13 files changed

+53
-50
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ repos:
5050
- repo: https://github.com/Lucas-C/pre-commit-hooks
5151
rev: v1.1.7
5252
hooks:
53-
- id: forbid-crlf
5453
- id: remove-crlf
54+
- id: forbid-crlf
5555

5656

5757
- repo: https://github.com/domdfcoding/yapf-isort

domdf_python_tools/doctools.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ def _do_prettify(obj: Type, base: Type, new_docstrings: Dict[str, str]):
329329
):
330330
continue
331331
elif PYPY and isinstance(attribute, MethodType):
332-
continue
332+
continue # pragma: no cover (!PyPy)
333333

334334
if attribute is None:
335335
continue

domdf_python_tools/paths.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
"PathPlus",
6767
"PosixPathPlus",
6868
"WindowsPathPlus",
69+
"in_directory",
6970
]
7071

7172
newline_default = object()
@@ -489,7 +490,7 @@ def read_lines(
489490

490491
return self.read_text(encoding=encoding, errors=errors).split("\n")
491492

492-
def open( # noqa A003
493+
def open( # type: ignore # noqa A003
493494
self,
494495
mode: str = "r",
495496
buffering: int = -1,
@@ -526,7 +527,14 @@ def open( # noqa A003
526527
else:
527528
newline = "\n"
528529

529-
return super().open(mode, buffering=buffering, encoding=encoding, errors=errors, newline=newline)
530+
return super(
531+
).open( # type: ignore
532+
mode,
533+
buffering=buffering,
534+
encoding=encoding,
535+
errors=errors,
536+
newline=newline,
537+
)
530538

531539
def dump_json(
532540
self,

domdf_python_tools/utils.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -72,19 +72,21 @@
7272
import textwrap
7373
import typing
7474
import warnings
75+
from datetime import date
7576
from pprint import pformat
7677
from typing import Any, Callable, Dict, Generator, Iterable, List, Optional, Sequence, Tuple, Union
7778

7879
# 3rd party
7980
import deprecation # type: ignore
81+
from packaging import version
8082

8183
# this package
8284
import domdf_python_tools.words
8385
from domdf_python_tools import __version__
8486
from domdf_python_tools.terminal_colours import Colour, Fore
8587
from domdf_python_tools.typing import HasHead, String
8688

87-
if typing.TYPE_CHECKING or domdf_python_tools.__docs:
89+
if typing.TYPE_CHECKING or domdf_python_tools.__docs: # pragma: no cover
8890
# 3rd party
8991
from pandas import DataFrame, Series # type: ignore
9092

@@ -110,6 +112,7 @@
110112
"convert_indents",
111113
"etc",
112114
"head",
115+
"coloured_diff",
113116
"deprecated",
114117
]
115118

@@ -270,7 +273,7 @@ def str2tuple(input_string: str, sep: str = ',') -> Tuple[int, ...]:
270273
return tuple(int(x) for x in input_string.split(sep))
271274

272275

273-
def strtobool(val: Union[str, bool]) -> bool:
276+
def strtobool(val: Union[str, int]) -> bool:
274277
"""
275278
Convert a string representation of truth to :py:obj:`True` or :py:obj:`False`.
276279
@@ -557,13 +560,6 @@ def coloured_diff(
557560
return str(buf)
558561

559562

560-
# stdlib
561-
from datetime import date
562-
563-
# 3rd party
564-
from packaging import version
565-
566-
567563
def deprecated(
568564
deprecated_in: Optional[str] = None,
569565
removed_in: Optional[str] = None,

setup.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
# this package
1313
from __pkginfo__ import * # pylint: disable=wildcard-import
1414

15-
16-
1715
setup(
1816
description='Helpful functions for Python\u2002🐍\u2002🛠️',
1917
extras_require=extras_require,

stubs.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
git+https://github.com/domdfcoding/pytest-regressions-stubs

tests/conftest.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pytest_plugins = ("domdf_python_tools.testing", )

tests/list_tests.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def test_init(self):
4848
def test_getitem_error(self):
4949
a = []
5050
with pytest.raises(TypeError, match="list indices must be integers or slices"):
51-
a['a']
51+
a['a'] # pylint: disable=pointless-statement
5252

5353
@no_type_check
5454
def test_setitem_error(self):

tests/seq_tests.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
# this package
2121
from domdf_python_tools.testing import not_pypy
22+
from domdf_python_tools.utils import Len
2223

2324

2425
class _ALWAYS_EQ:
@@ -139,7 +140,7 @@ def __iter__(self):
139140
return self
140141

141142
def __next__(self):
142-
3 // 0
143+
3 // 0 # pylint: disable=pointless-statement
143144

144145

145146
class IterFuncStop:
@@ -242,7 +243,7 @@ def test_truth(self):
242243

243244
def test_getitem(self):
244245
u = self.type2test([0, 1, 2, 3, 4])
245-
for i in range(len(u)):
246+
for i in Len(u):
246247
self.assertEqual(u[i], i)
247248
self.assertEqual(u[int(i)], i)
248249
for i in range(-len(u), -1):

tests/test_pretty_print.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
# 3rd party
1818
import pytest
19-
from pytest_regressions.file_regression import FileRegressionFixture # type: ignore
19+
from pytest_regressions.file_regression import FileRegressionFixture
2020

2121
# this package
2222
from domdf_python_tools.pretty_print import FancyPrinter, simple_repr
@@ -578,8 +578,8 @@ def test_sort_orderable_and_unorderable_values(self):
578578
# self-test
579579
assert a < b
580580
assert str(type(b)) < str(type(a))
581-
assert sorted([b, a]) == [a, b]
582-
assert sorted([a, b]) == [a, b]
581+
assert sorted([b, a]) == [a, b] # type: ignore
582+
assert sorted([a, b]) == [a, b] # type: ignore
583583
# set
584584
assert FancyPrinter(width=1).pformat({b, a}) == f'{{\n {a!r},\n {b!r},\n }}'
585585
assert FancyPrinter(width=1).pformat({a, b}) == f'{{\n {a!r},\n {b!r},\n }}'
@@ -703,7 +703,7 @@ def test_compact_width(self):
703703
lines = FancyPrinter(width=w, compact=True).pformat(o, ).splitlines()
704704
maxwidth = max(map(len, lines))
705705
assert maxwidth <= w
706-
maxwidth > w - 3
706+
maxwidth > w - 3 # pylint: disable=pointless-statement
707707

708708
def test_bytes_wrap(self):
709709
assert FancyPrinter(width=1).pformat(b'') == "b''"

0 commit comments

Comments
 (0)