Skip to content

Commit 74e25d4

Browse files
committed
Lint
1 parent 25925cd commit 74e25d4

File tree

5 files changed

+15
-16
lines changed

5 files changed

+15
-16
lines changed

snippet_fmt/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
__version__: str = "0.1.4"
5757
__email__: str = "dominic@davis-foster.co.uk"
5858

59-
__all__ = ["CodeBlockError", "RSTReformatter", "reformat_file"]
59+
__all__ = ("CodeBlockError", "RSTReformatter", "reformat_file")
6060

6161
TRAILING_NL_RE = re.compile(r'\n+\Z', re.MULTILINE)
6262

@@ -227,7 +227,7 @@ def load_extra_formatters(self) -> None:
227227
for distro_config, _ in entrypoints.iter_files_distros():
228228
if group in distro_config:
229229
for name, epstr in distro_config[group].items():
230-
with contextlib.suppress(entrypoints.BadEntryPoint, ImportError):
230+
with contextlib.suppress(entrypoints.BadEntryPoint, ImportError): # pylint: disable=W8205
231231
# TODO: show warning for bad entry point if verbose, or "strict"?
232232
ep = entrypoints.EntryPoint.from_string(epstr, name)
233233
self._formatters[name] = ep.load()
@@ -237,7 +237,7 @@ def reformat_file(
237237
filename: PathLike,
238238
config: SnippetFmtConfigDict,
239239
colour: ColourTrilean = None,
240-
):
240+
) -> int:
241241
"""
242242
Reformat the given reStructuredText file, and show the diff if changes were made.
243243

snippet_fmt/__main__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
from consolekit.tracebacks import handle_tracebacks, traceback_option
3939
from domdf_python_tools.typing import PathLike
4040

41-
__all__ = ["main"]
41+
__all__ = ("main", )
4242

4343

4444
@flag_option("--diff", "show_diff", help="Show a diff of changes made")
@@ -71,7 +71,7 @@ def main(
7171
verbose: bool = False,
7272
show_traceback: bool = False,
7373
show_diff: bool = False,
74-
):
74+
) -> None:
7575
"""
7676
Reformat code snippets in the given reStructuredText files.
7777
"""
@@ -97,7 +97,7 @@ def main(
9797

9898
for path in filename:
9999
for pattern in exclude or []:
100-
if re.match(fnmatch.translate(pattern), str(path)):
100+
if re.match(fnmatch.translate(pattern), str(path)): # pylint: disable=loop-invariant-statement
101101
continue
102102

103103
path = PathPlus(path).abspath()

snippet_fmt/config.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
from domdf_python_tools.typing import PathLike
3535
from typing_extensions import TypedDict
3636

37-
__all__ = ["SnippetFmtConfigDict", "load_toml"]
37+
__all__ = ("SnippetFmtConfigDict", "load_toml")
3838

3939

4040
class SnippetFmtConfigDict(TypedDict):
@@ -98,7 +98,7 @@ def load_toml(filename: PathLike) -> SnippetFmtConfigDict:
9898

9999
if "languages" in config:
100100
for language, lang_config in config.get("languages", {}).items():
101-
snippet_fmt_config["languages"][language] = lang_config
101+
snippet_fmt_config["languages"][language] = lang_config # pylint: disable=loop-invariant-statement
102102
else:
103103
snippet_fmt_config["languages"] = {
104104
"python": {},

snippet_fmt/formatters.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,22 +32,22 @@
3232
import os
3333
from configparser import ConfigParser
3434
from io import StringIO
35-
from typing import Any, Callable, Optional, TypeVar
35+
from typing import Any, Optional
3636

3737
# 3rd party
3838
import dom_toml
3939
import dom_toml.decoder
4040
import formate
4141
from domdf_python_tools.paths import PathPlus
4242

43-
__all__ = [
43+
__all__ = (
4444
"Formatter",
4545
"format_toml",
4646
"format_ini",
4747
"format_json",
4848
"format_python",
4949
"noformat",
50-
]
50+
)
5151

5252
# 3rd party
5353
from typing_extensions import Protocol

tests/test_snippet_fmt.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# stdlib
2-
import re
3-
from typing import Dict, List, Union, no_type_check
2+
from typing import Dict, Iterator, List, Union, no_type_check
43

54
# 3rd party
65
import dom_toml
@@ -69,7 +68,7 @@
6968

7069

7170
@pytest.fixture()
72-
def custom_entry_point(monkeypatch):
71+
def custom_entry_point(monkeypatch) -> Iterator:
7372
with TemporaryPathPlus() as tmpdir:
7473
monkeypatch.syspath_prepend(str(tmpdir))
7574

@@ -114,6 +113,7 @@ def test_snippet_fmt(
114113
advanced_file_regression.check_file(tmp_pathplus / filename)
115114
check_out(capsys.readouterr(), tmp_pathplus, advanced_data_regression)
116115

116+
@pytest.mark.usefixtures("custom_entry_point")
117117
@filenames
118118
def test_snippet_fmt_custom_entry_point(
119119
self,
@@ -122,7 +122,6 @@ def test_snippet_fmt_custom_entry_point(
122122
advanced_file_regression: AdvancedFileRegressionFixture,
123123
advanced_data_regression: AdvancedDataRegressionFixture,
124124
capsys,
125-
custom_entry_point
126125
):
127126

128127
languages = {"python3": {"reformat": True}}
@@ -191,7 +190,7 @@ def check_out(
191190
result: Union[Result, CaptureResult[str]],
192191
tmpdir: PathPlus,
193192
advanced_data_regression: AdvancedDataRegressionFixture,
194-
):
193+
) -> None:
195194

196195
if hasattr(result, "stdout"):
197196
stdout = result.stdout

0 commit comments

Comments
 (0)