From nobody Sat Oct 4 00:28:10 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BA1FC3126B0; Fri, 22 Aug 2025 14:19:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755872388; cv=none; b=sOLX1+VKJdU1Kblk2zUBGvw6IM5RDQE4LD/5L1Oxtnqrb+elzJvTgfIOKF10Tgbhv2CvUtmZhEqZx4+1XU4pNmZsdJD7wY9W0qZrX+sHH4LHg+bmd1d0/KW8CkZhIk4gc96/p8Cs1k56hBqDHevqvMSPZ9wg2v5KgK9BMeXWKuc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755872388; c=relaxed/simple; bh=QHi7tmIl6nunuTAnM3ij6+YulhA5kpLqxpviwyDbWAA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RkLNEYDelZHJBiAu9xW5z0NLNKSYIScaR17okbZ6mqGBEA9Hfwa2Olb98SsYShJ8Z/zVR39YyHP1KPtP8yd59HnSYgK7euAKYjOZiXjvmvUfe+UWXCeS5BlJsEJERUneTswasYeQUIPOrqBN5E06BYPJRpebFm9kgArtWYCh4H4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=TeGepcH5; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="TeGepcH5" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 231EAC19422; Fri, 22 Aug 2025 14:19:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1755872388; bh=QHi7tmIl6nunuTAnM3ij6+YulhA5kpLqxpviwyDbWAA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TeGepcH5/5qli8litD44Aq0Yhvo7gooOdf6YxyWLW14sag1XnYh9sXlY5+rNfENRG k/5uhjfW8odFPXY5jpTmW8p+O5j+9jIqIRc36zxprsRN2RV1P5LE9fK4gCE3o+wl+u pHllJS+D3v/XpGrxcIkdsCIzJLCEZWToimYSt7VKAJ1SDCAuToP2+XCTLHcQgk+ebh Lryuxo0EHAwm9FaluZ8RO5GuIuAbvzDujETiRNeKG5ShxMwXf3GQE5D0Y1Lfpu0Cew moKCbkodchFj16iHEz9WLUa901oOmlyNGX7lhZBaTeqScmt5UlfMqu8kyEvNHYcwTb uFIyH9QBh5zBQ== Received: from mchehab by mail.kernel.org with local (Exim 4.98.2) (envelope-from ) id 1upScM-0000000CCrV-1Yej; Fri, 22 Aug 2025 16:19:46 +0200 From: Mauro Carvalho Chehab To: Jonathan Corbet , Linux Doc Mailing List Cc: Mauro Carvalho Chehab , "Mauro Carvalho Chehab" , Kees Cook , linux-kernel@vger.kernel.org Subject: [PATCH v2 10/24] docs: kernel_include.py: Update its coding style Date: Fri, 22 Aug 2025 16:19:22 +0200 Message-ID: X-Mailer: git-send-email 2.50.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: Mauro Carvalho Chehab Content-Type: text/plain; charset="utf-8" With the help of tools like black, pylint, autopep8 and flake, improve the code style in preparation for further changes. No functional changes. Signed-off-by: Mauro Carvalho Chehab --- Documentation/sphinx/kernel_include.py | 100 ++++++++++++------------- 1 file changed, 47 insertions(+), 53 deletions(-) diff --git a/Documentation/sphinx/kernel_include.py b/Documentation/sphinx/= kernel_include.py index 1e566e87ebcd..1212786ac516 100755 --- a/Documentation/sphinx/kernel_include.py +++ b/Documentation/sphinx/kernel_include.py @@ -1,7 +1,6 @@ #!/usr/bin/env python3 -# -*- coding: utf-8; mode: python -*- # SPDX-License-Identifier: GPL-2.0 -# pylint: disable=3DR0903, C0330, R0914, R0912, E0401 +# pylint: disable=3DR0903, R0912, R0914, R0915, C0209,W0707 =20 """ kernel-include @@ -40,41 +39,38 @@ from docutils.parsers.rst import directives from docutils.parsers.rst.directives.body import CodeBlock, NumberLines from docutils.parsers.rst.directives.misc import Include =20 -__version__ =3D '1.0' +__version__ =3D "1.0" + =20 # =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D def setup(app): -# =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D - + """Setup Sphinx exension""" app.add_directive("kernel-include", KernelInclude) - return dict( - version =3D __version__, - parallel_read_safe =3D True, - parallel_write_safe =3D True - ) + return { + "version": __version__, + "parallel_read_safe": True, + "parallel_write_safe": True, + } + =20 # =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D class KernelInclude(Include): -# =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D - """KernelInclude (``kernel-include``) directive""" =20 def run(self): env =3D self.state.document.settings.env - path =3D os.path.realpath( - os.path.expandvars(self.arguments[0])) + path =3D os.path.realpath(os.path.expandvars(self.arguments[0])) =20 # to get a bit security back, prohibit /etc: if path.startswith(os.sep + "etc"): - raise self.severe( - 'Problems with "%s" directive, prohibited path: %s' - % (self.name, path)) + raise self.severe('Problems with "%s" directive, prohibited pa= th: %s' % + (self.name, path)) =20 self.arguments[0] =3D path =20 env.note_dependency(os.path.abspath(path)) =20 - #return super(KernelInclude, self).run() # won't work, see HINTs i= n _run() + # return super(KernelInclude, self).run() # won't work, see HINTs = in _run() return self._run() =20 def _run(self): @@ -87,41 +83,39 @@ class KernelInclude(Include): =20 if not self.state.document.settings.file_insertion_enabled: raise self.warning('"%s" directive disabled.' % self.name) - source =3D self.state_machine.input_lines.source( - self.lineno - self.state_machine.input_offset - 1) + source =3D self.state_machine.input_lines.source(self.lineno - + self.state_machine.= input_offset - 1) source_dir =3D os.path.dirname(os.path.abspath(source)) path =3D directives.path(self.arguments[0]) - if path.startswith('<') and path.endswith('>'): + if path.startswith("<") and path.endswith(">"): path =3D os.path.join(self.standard_include_path, path[1:-1]) path =3D os.path.normpath(os.path.join(source_dir, path)) =20 # HINT: this is the only line I had to change / commented out: - #path =3D utils.relative_path(None, path) + # path =3D utils.relative_path(None, path) =20 - encoding =3D self.options.get( - 'encoding', self.state.document.settings.input_encoding) - e_handler=3Dself.state.document.settings.input_encoding_error_hand= ler - tab_width =3D self.options.get( - 'tab-width', self.state.document.settings.tab_width) + encoding =3D self.options.get("encoding", + self.state.document.settings.input_enc= oding) + e_handler =3D self.state.document.settings.input_encoding_error_ha= ndler + tab_width =3D self.options.get("tab-width", + self.state.document.settings.tab_widt= h) try: self.state.document.settings.record_dependencies.add(path) - include_file =3D io.FileInput(source_path=3Dpath, - encoding=3Dencoding, + include_file =3D io.FileInput(source_path=3Dpath, encoding=3De= ncoding, error_handler=3De_handler) - except UnicodeEncodeError as error: + except UnicodeEncodeError: raise self.severe('Problems with "%s" directive path:\n' 'Cannot encode input file path "%s" ' - '(wrong locale?).' % - (self.name, SafeString(path))) + "(wrong locale?)." % (self.name, SafeString(= path))) except IOError as error: - raise self.severe('Problems with "%s" directive path:\n%s.' % - (self.name, ErrorString(error))) - startline =3D self.options.get('start-line', None) - endline =3D self.options.get('end-line', None) + raise self.severe('Problems with "%s" directive path:\n%s.' + % (self.name, ErrorString(error))) + startline =3D self.options.get("start-line", None) + endline =3D self.options.get("end-line", None) try: if startline or (endline is not None): lines =3D include_file.readlines() - rawtext =3D ''.join(lines[startline:endline]) + rawtext =3D "".join(lines[startline:endline]) else: rawtext =3D include_file.read() except UnicodeError as error: @@ -129,43 +123,43 @@ class KernelInclude(Include): (self.name, ErrorString(error))) # start-after/end-before: no restrictions on newlines in match-tex= t, # and no restrictions on matching inside lines vs. line boundaries - after_text =3D self.options.get('start-after', None) + after_text =3D self.options.get("start-after", None) if after_text: # skip content in rawtext before *and incl.* a matching text after_index =3D rawtext.find(after_text) if after_index < 0: raise self.severe('Problem with "start-after" option of "%= s" ' - 'directive:\nText not found.' % self.nam= e) - rawtext =3D rawtext[after_index + len(after_text):] - before_text =3D self.options.get('end-before', None) + "directive:\nText not found." % self.nam= e) + rawtext =3D rawtext[after_index + len(after_text) :] + before_text =3D self.options.get("end-before", None) if before_text: # skip content in rawtext after *and incl.* a matching text before_index =3D rawtext.find(before_text) if before_index < 0: raise self.severe('Problem with "end-before" option of "%s= " ' - 'directive:\nText not found.' % self.nam= e) + "directive:\nText not found." % self.nam= e) rawtext =3D rawtext[:before_index] =20 include_lines =3D statemachine.string2lines(rawtext, tab_width, convert_whitespace=3DTru= e) - if 'literal' in self.options: + if "literal" in self.options: # Convert tabs to spaces, if `tab_width` is positive. if tab_width >=3D 0: text =3D rawtext.expandtabs(tab_width) else: text =3D rawtext literal_block =3D nodes.literal_block(rawtext, source=3Dpath, - classes=3Dself.options.get('class', []= )) + classes=3Dself.options.get= ("class", []) + ) literal_block.line =3D 1 self.add_name(literal_block) - if 'number-lines' in self.options: + if "number-lines" in self.options: try: - startline =3D int(self.options['number-lines'] or 1) + startline =3D int(self.options["number-lines"] or 1) except ValueError: - raise self.error(':number-lines: with non-integer ' - 'start value') + raise self.error(":number-lines: with non-integer star= t value") endline =3D startline + len(include_lines) - if text.endswith('\n'): + if text.endswith("\n"): text =3D text[:-1] tokens =3D NumberLines([([], text)], startline, endline) for classes, value in tokens: @@ -177,12 +171,12 @@ class KernelInclude(Include): else: literal_block +=3D nodes.Text(text, text) return [literal_block] - if 'code' in self.options: - self.options['source'] =3D path + if "code" in self.options: + self.options["source"] =3D path codeblock =3D CodeBlock(self.name, - [self.options.pop('code')], # arguments + [self.options.pop("code")], # arguments self.options, - include_lines, # content + include_lines, # content self.lineno, self.content_offset, self.block_text, --=20 2.50.1