From 1cf4f30d5b313ba8bb63d974fb3e8a87100d5a9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20van=20Noord?= <13665637+DanielNoord@users.noreply.github.com> Date: Sun, 10 Oct 2021 16:57:46 +0200 Subject: [PATCH] Remove calls to ``os.linesep`` and add misc. typing --- pylint/reporters/ureports/base_writer.py | 3 +-- pylint/utils/utils.py | 5 +++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pylint/reporters/ureports/base_writer.py b/pylint/reporters/ureports/base_writer.py index 418079ae0..edf588527 100644 --- a/pylint/reporters/ureports/base_writer.py +++ b/pylint/reporters/ureports/base_writer.py @@ -16,7 +16,6 @@ A way to create simple reports using python objects, primarily designed to be formatted as text and html. """ -import os import sys from io import StringIO from typing import TYPE_CHECKING, Iterator, List, TextIO, Union @@ -59,7 +58,7 @@ class BaseWriter: def writeln(self, string: str = "") -> None: """write a line in the output buffer""" - self.write(string + os.linesep) + self.write(string + "\n") def write(self, string: str) -> None: """write a string in the output buffer""" diff --git a/pylint/utils/utils.py b/pylint/utils/utils.py index d8d4baf0a..96f8a6acc 100644 --- a/pylint/utils/utils.py +++ b/pylint/utils/utils.py @@ -302,10 +302,11 @@ def _check_csv(value): return _splitstrip(value) -def _comment(string): +def _comment(string: str) -> str: """return string as a comment""" lines = [line.strip() for line in string.splitlines()] - return "# " + f"{os.linesep}# ".join(lines) + sep = "\n" + return "# " + f"{sep}# ".join(lines) def _format_option_value(optdict, value):