mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Enable the PLW0108 lint in Ruff
This commit is contained in:
parent
e9274771b3
commit
f9947ff197
@ -57,7 +57,6 @@ ignore = [
|
|||||||
"PLR6201", # Use a set literal when testing for membership
|
"PLR6201", # Use a set literal when testing for membership
|
||||||
"PLR6301", # Method `{method_name}` could be a function, class method, or static method
|
"PLR6301", # Method `{method_name}` could be a function, class method, or static method
|
||||||
# pylint ('PLW')
|
# pylint ('PLW')
|
||||||
"PLW0108", # Lambda may be unnecessary; consider inlining inner function
|
|
||||||
"PLW0211", # First argument of a static method should not be named `{argument_name}`
|
"PLW0211", # First argument of a static method should not be named `{argument_name}`
|
||||||
"PLW0603", # Using the global statement to update `{name}` is discouraged
|
"PLW0603", # Using the global statement to update `{name}` is discouraged
|
||||||
"PLW1514", # `{function_name}` in text mode without explicit `encoding` argument
|
"PLW1514", # `{function_name}` in text mode without explicit `encoding` argument
|
||||||
|
@ -17,18 +17,18 @@ class XMLWriter(BaseXMLWriter): # type: ignore[misc]
|
|||||||
super().__init__()
|
super().__init__()
|
||||||
self.builder = builder
|
self.builder = builder
|
||||||
|
|
||||||
# A lambda function to generate translator lazily
|
|
||||||
self.translator_class = lambda document: self.builder.create_translator(
|
|
||||||
document
|
|
||||||
)
|
|
||||||
|
|
||||||
def translate(self, *args: Any, **kwargs: Any) -> None:
|
def translate(self, *args: Any, **kwargs: Any) -> None:
|
||||||
self.document.settings.newlines = self.document.settings.indents = (
|
self.document.settings.newlines = self.document.settings.indents = (
|
||||||
self.builder.env.config.xml_pretty
|
self.builder.env.config.xml_pretty
|
||||||
)
|
)
|
||||||
self.document.settings.xml_declaration = True
|
self.document.settings.xml_declaration = True
|
||||||
self.document.settings.doctype_declaration = True
|
self.document.settings.doctype_declaration = True
|
||||||
return super().translate()
|
|
||||||
|
# copied from docutils.writers.docutils_xml.Writer.translate()
|
||||||
|
# so that we can override the translator class
|
||||||
|
self.visitor = visitor = self.builder.create_translator(self.document)
|
||||||
|
self.document.walkabout(visitor)
|
||||||
|
self.output = ''.join(visitor.output) # type: ignore[attr-defined]
|
||||||
|
|
||||||
|
|
||||||
class PseudoXMLWriter(BaseXMLWriter): # type: ignore[misc]
|
class PseudoXMLWriter(BaseXMLWriter): # type: ignore[misc]
|
||||||
|
Loading…
Reference in New Issue
Block a user