Skip to content

Commit bee3a16

Browse files
committed
Linting.
1 parent 4b38f95 commit bee3a16

29 files changed

+433
-425
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ repos:
5858
- id: forbid-crlf
5959

6060
- repo: https://github.com/domdfcoding/yapf-isort
61-
rev: v0.4.4
61+
rev: v0.5.1
6262
hooks:
6363
- id: yapf-isort
6464
exclude: ^(doc-source/conf|__pkginfo__|make_conda_recipe|setup)\.py$

doc-source/patched_autosummary.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ def import_by_name(self, name: str, prefixes: List[str]) -> Tuple[str, Any, Any,
2626

2727

2828
def setup(app: Sphinx) -> Dict[str, Any]:
29-
app.setup_extension('sphinx.ext.autosummary')
30-
app.add_directive('autosummary', PatchedAutosummary, override=True)
29+
app.setup_extension("sphinx.ext.autosummary")
30+
app.add_directive("autosummary", PatchedAutosummary, override=True)
3131

3232
return {
33-
'version': f"{sphinx.__display_version__}-patched-autosummary-0",
34-
'parallel_read_safe': True,
33+
"version": f"{sphinx.__display_version__}-patched-autosummary-0",
34+
"parallel_read_safe": True,
3535
}

domdf_python_tools/doctools.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
from domdf_python_tools.typing import MethodDescriptorType, MethodWrapperType, WrapperDescriptorType
3838

3939
__all__ = [
40-
"F",
40+
'F',
4141
"deindent_string",
4242
"document_object_from_another",
4343
"append_doctring_from_another",
@@ -65,9 +65,9 @@ def deindent_string(string: Optional[str]) -> str:
6565
# Short circuit if empty string or None
6666
return ''
6767

68-
split_string = string.split("\n")
68+
split_string = string.split('\n')
6969
deindented_string = [line.lstrip("\t ") for line in split_string]
70-
return "\n".join(deindented_string)
70+
return '\n'.join(deindented_string)
7171

7272

7373
# Functions that do the work

domdf_python_tools/paths.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ def write_clean(
358358
.. versionadded:: 0.3.8
359359
"""
360360

361-
with self.open("w", encoding=encoding, errors=errors) as fp:
361+
with self.open('w', encoding=encoding, errors=errors) as fp:
362362
clean_writer(string, fp)
363363

364364
def maybe_make(
@@ -411,7 +411,7 @@ def append_text(
411411
.. versionadded:: 0.3.8
412412
"""
413413

414-
with self.open("a", encoding=encoding, errors=errors) as fp:
414+
with self.open('a', encoding=encoding, errors=errors) as fp:
415415
fp.write(string)
416416

417417
def write_text(
@@ -450,7 +450,7 @@ def write_lines(
450450
.. versionadded:: 0.5.0
451451
""" # noqa D400
452452

453-
return self.write_clean("\n".join(data), encoding=encoding, errors=errors)
453+
return self.write_clean('\n'.join(data), encoding=encoding, errors=errors)
454454

455455
def read_text(
456456
self,
@@ -487,11 +487,11 @@ def read_lines(
487487
.. versionadded:: 0.5.0
488488
""" # noqa D400
489489

490-
return self.read_text(encoding=encoding, errors=errors).split("\n")
490+
return self.read_text(encoding=encoding, errors=errors).split('\n')
491491

492492
def open( # type: ignore # noqa A003
493493
self,
494-
mode: str = "r",
494+
mode: str = 'r',
495495
buffering: int = -1,
496496
encoding: Optional[str] = "UTF-8",
497497
errors: Optional[str] = None,
@@ -524,7 +524,7 @@ def open( # type: ignore # noqa A003
524524
if 'r' in mode:
525525
newline = None
526526
else:
527-
newline = "\n"
527+
newline = '\n'
528528

529529
return super().open(
530530
mode,

domdf_python_tools/stringlist.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class Indent:
4848
:param type: The indent character.
4949
"""
5050

51-
def __init__(self, size: int = 0, type: str = "\t"): # noqa A002 # pylint: disable=redefined-builtin
51+
def __init__(self, size: int = 0, type: str = '\t'): # noqa A002 # pylint: disable=redefined-builtin
5252
self.size = int(size)
5353
self.type = str(type)
5454

@@ -134,18 +134,18 @@ class StringList(List[str]):
134134

135135
def __init__(self, iterable: Iterable[String] = (), convert_indents: bool = False) -> None:
136136
if isinstance(iterable, str):
137-
iterable = iterable.split("\n")
137+
iterable = iterable.split('\n')
138138

139139
self.indent = Indent()
140140
self.convert_indents = convert_indents
141141
super().__init__([self._make_line(str(x)) for x in iterable])
142142

143143
def _make_line(self, line: str) -> str:
144144
if not str(self.indent_type).strip(" \t") and self.convert_indents:
145-
if self.indent_type == "\t":
146-
line = convert_indents(line, tab_width=1, from_=" ", to="\t")
145+
if self.indent_type == '\t':
146+
line = convert_indents(line, tab_width=1, from_=" ", to='\t')
147147
else: # pragma: no cover
148-
line = convert_indents(line, tab_width=1, from_="\t", to=self.indent_type)
148+
line = convert_indents(line, tab_width=1, from_='\t', to=self.indent_type)
149149

150150
return f"{self.indent}{line}".rstrip()
151151

@@ -156,7 +156,7 @@ def append(self, line: String) -> None:
156156
:param line:
157157
"""
158158

159-
for inner_line in str(line).split("\n"):
159+
for inner_line in str(line).split('\n'):
160160
super().append(self._make_line(inner_line))
161161

162162
def extend(self, iterable: Iterable[String]) -> None:
@@ -199,9 +199,9 @@ def insert(self, index: int, line: String) -> None:
199199
lines: List[str]
200200

201201
if index < 0 or index > len(self):
202-
lines = str(line).split("\n")
202+
lines = str(line).split('\n')
203203
else:
204-
lines = cast(list, reversed(str(line).split("\n")))
204+
lines = cast(list, reversed(str(line).split('\n')))
205205

206206
for inner_line in lines:
207207
super().insert(index, self._make_line(inner_line))
@@ -278,7 +278,7 @@ def set_indent_size(self, size: int = 0):
278278

279279
self.indent.size = int(size)
280280

281-
def set_indent_type(self, indent_type: str = "\t"):
281+
def set_indent_type(self, indent_type: str = '\t'):
282282
"""
283283
Sets the type of the indent to insert at the beginning of new lines.
284284
@@ -340,7 +340,7 @@ def __str__(self) -> str:
340340
Returns the :class:`~domdf_python_tools.stringlist.StringList` as a string.
341341
"""
342342

343-
return "\n".join(self)
343+
return '\n'.join(self)
344344

345345
def __eq__(self, other) -> bool:
346346
"""
@@ -398,7 +398,7 @@ def with_indent_size(self, size: int = 0):
398398
self.indent_size = original_indent_size
399399

400400
@contextmanager
401-
def with_indent_type(self, indent_type: str = "\t"):
401+
def with_indent_type(self, indent_type: str = '\t'):
402402
"""
403403
Context manager to temporarily use a different indent type.
404404

domdf_python_tools/terminal.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ def clear() -> None:
8888
if os.name == "nt": # pragma: no cover (!Windows)
8989
os.system("cls") # nosec: B607,B605
9090
else: # pragma: no cover (!Linux)
91-
print("\033c", end='')
91+
print("\u001bc", end='')
9292

9393

9494
def br() -> None:
@@ -170,7 +170,7 @@ class Echo:
170170
:param indent: The indentation of the dictionary of variable assignments.
171171
"""
172172

173-
def __init__(self, indent: str = " " * 2):
173+
def __init__(self, indent: str = ' ' * 2):
174174
self.indent = indent
175175

176176
frame = inspect.currentframe()

domdf_python_tools/utils.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ def posargs2kwargs(
276276
return kwargs
277277

278278

279-
def convert_indents(text: str, tab_width: int = 4, from_: str = "\t", to: str = " ") -> str:
279+
def convert_indents(text: str, tab_width: int = 4, from_: str = '\t', to: str = ' ') -> str:
280280
r"""
281281
Convert indentation at the start of lines in ``text`` from tabs to spaces.
282282
@@ -299,7 +299,7 @@ def convert_indents(text: str, tab_width: int = 4, from_: str = "\t", to: str =
299299

300300
output.append(f"{tab * indent_count}{line}")
301301

302-
return "\n".join(output)
302+
return '\n'.join(output)
303303

304304

305305
class _Etcetera(str):
@@ -451,7 +451,7 @@ def _function_wrapper(function):
451451
existing_docstring = function.__doc__ or ''
452452

453453
# split docstring at first occurrence of newline
454-
string_list = existing_docstring.split("\n", 1)
454+
string_list = existing_docstring.split('\n', 1)
455455

456456
if should_warn:
457457
# The various parts of this decorator being optional makes for
@@ -495,7 +495,7 @@ def _function_wrapper(function):
495495
string_list[1] = textwrap.dedent(string_list[1])
496496

497497
# we need another newline
498-
string_list.insert(loc, "\n")
498+
string_list.insert(loc, '\n')
499499

500500
# change the message_location if we add to end of docstring
501501
# do this always if not "top"

domdf_python_tools/versions.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,14 +102,14 @@ def __str__(self) -> str:
102102
Return version as a string.
103103
"""
104104

105-
return "v" + ".".join(str(x) for x in self) # pylint: disable=not-an-iterable
105+
return 'v' + '.'.join(str(x) for x in self) # pylint: disable=not-an-iterable
106106

107107
def __float__(self) -> float:
108108
"""
109109
Return the major and minor version number as a float.
110110
"""
111111

112-
return float(".".join(str(x) for x in self[:2]))
112+
return float('.'.join(str(x) for x in self[:2]))
113113

114114
def __int__(self) -> int:
115115
"""

domdf_python_tools/words.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,7 @@ def word_join(
500500
iterable: Iterable[str],
501501
use_repr: bool = False,
502502
oxford: bool = False,
503-
delimiter: str = ",",
503+
delimiter: str = ',',
504504
connective: str = "and",
505505
) -> str:
506506
"""
@@ -540,21 +540,21 @@ def word_join(
540540
return delimiter.join(words[:-1]) + f" {connective} {words[-1]}"
541541

542542

543-
TAB = "\t"
543+
TAB = '\t'
544544
"""
545545
A literal ``TAB`` (``\\t``) character for use in f-strings.
546546
547547
.. versionadded:: 1.3.0
548548
"""
549549

550-
CR = "\r"
550+
CR = '\r'
551551
"""
552552
The carriage return character (``\\r``) for use in f-strings.
553553
554554
.. versionadded:: 1.3.0
555555
"""
556556

557-
LF = "\r"
557+
LF = '\r'
558558
"""
559559
The newline character (``\\n``) for use in f-strings.
560560

tests/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@
1111
@pytest.fixture()
1212
def original_datadir(request) -> Path:
1313
# Work around pycharm confusing datadir with test file.
14-
return Path(os.path.splitext(request.module.__file__)[0] + "_")
14+
return Path(os.path.splitext(request.module.__file__)[0] + '_')

0 commit comments

Comments
 (0)