mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Remove calls to `builtins.print()
`
This commit is contained in:
parent
53a930f8c7
commit
ffb14f59bc
@ -299,18 +299,38 @@ select = [
|
||||
[tool.ruff.per-file-ignores]
|
||||
"doc/conf.py" = ["INP001"]
|
||||
"doc/development/tutorials/examples/*" = ["INP001"]
|
||||
# allow print() in the tutorial
|
||||
"doc/development/tutorials/examples/recipe.py" = ["T201"]
|
||||
|
||||
# whitelist ``print`` for stdout messages
|
||||
"sphinx/cmd/build.py" = ["T201"]
|
||||
"sphinx/cmd/make_mode.py" = ["T201"]
|
||||
"sphinx/cmd/quickstart.py" = ["T201"]
|
||||
|
||||
"sphinx/environment/collectors/toctree.py" = ["B026"]
|
||||
"sphinx/environment/adapters/toctree.py" = ["B026"]
|
||||
|
||||
# whitelist ``print`` for stdout messages
|
||||
"sphinx/ext/intersphinx.py" = ["T201"]
|
||||
|
||||
# whitelist ``print`` for stdout messages
|
||||
"sphinx/testing/fixtures.py" = ["T201"]
|
||||
|
||||
# Ruff bug: https://github.com/astral-sh/ruff/issues/6540
|
||||
"sphinx/transforms/i18n.py" = ["PGH004"]
|
||||
|
||||
"tests/*" = ["E501"]
|
||||
"tests/*" = [
|
||||
"E501",
|
||||
"T201" # whitelist ``print`` for tests
|
||||
]
|
||||
|
||||
# these tests need old ``typing`` generic aliases
|
||||
"tests/test_util_typing.py" = ["UP006", "UP035"]
|
||||
"tests/typing_test_data.py" = ["UP006", "UP035"]
|
||||
|
||||
# whitelist ``print`` for stdout messages
|
||||
"utils/*" = ["T201"]
|
||||
|
||||
[tool.ruff.flake8-quotes]
|
||||
inline-quotes = "single"
|
||||
|
||||
|
@ -1555,8 +1555,8 @@ class Symbol:
|
||||
|
||||
@staticmethod
|
||||
def debug_print(*args: Any) -> None:
|
||||
print(Symbol.debug_indent_string * Symbol.debug_indent, end="")
|
||||
print(*args)
|
||||
logger.debug(Symbol.debug_indent_string * Symbol.debug_indent, end="")
|
||||
logger.debug(*args)
|
||||
|
||||
def _assert_invariants(self) -> None:
|
||||
if not self.parent:
|
||||
@ -1733,7 +1733,7 @@ class Symbol:
|
||||
Symbol.debug_print("_find_named_symbols:")
|
||||
Symbol.debug_indent += 1
|
||||
Symbol.debug_print("self:")
|
||||
print(self.to_string(Symbol.debug_indent + 1), end="")
|
||||
logger.debug(self.to_string(Symbol.debug_indent + 1), end="")
|
||||
Symbol.debug_print("ident: ", ident)
|
||||
Symbol.debug_print("matchSelf: ", matchSelf)
|
||||
Symbol.debug_print("recurseInAnon: ", recurseInAnon)
|
||||
@ -1743,7 +1743,7 @@ class Symbol:
|
||||
s = self
|
||||
if Symbol.debug_lookup:
|
||||
Symbol.debug_print("searching in self:")
|
||||
print(s.to_string(Symbol.debug_indent + 1), end="")
|
||||
logger.debug(s.to_string(Symbol.debug_indent + 1), end="")
|
||||
while True:
|
||||
if matchSelf:
|
||||
yield s
|
||||
@ -1757,12 +1757,12 @@ class Symbol:
|
||||
s = s.siblingAbove
|
||||
if Symbol.debug_lookup:
|
||||
Symbol.debug_print("searching in sibling:")
|
||||
print(s.to_string(Symbol.debug_indent + 1), end="")
|
||||
logger.debug(s.to_string(Symbol.debug_indent + 1), end="")
|
||||
|
||||
for s in candidates():
|
||||
if Symbol.debug_lookup:
|
||||
Symbol.debug_print("candidate:")
|
||||
print(s.to_string(Symbol.debug_indent + 1), end="")
|
||||
logger.debug(s.to_string(Symbol.debug_indent + 1), end="")
|
||||
if s.ident == ident:
|
||||
if Symbol.debug_lookup:
|
||||
Symbol.debug_indent += 1
|
||||
@ -1790,7 +1790,7 @@ class Symbol:
|
||||
Symbol.debug_print("_symbol_lookup:")
|
||||
Symbol.debug_indent += 1
|
||||
Symbol.debug_print("self:")
|
||||
print(self.to_string(Symbol.debug_indent + 1), end="")
|
||||
logger.debug(self.to_string(Symbol.debug_indent + 1), end="")
|
||||
Symbol.debug_print("nestedName: ", nestedName)
|
||||
Symbol.debug_print("ancestorLookupType:", ancestorLookupType)
|
||||
Symbol.debug_print("matchSelf: ", matchSelf)
|
||||
@ -1817,7 +1817,7 @@ class Symbol:
|
||||
|
||||
if Symbol.debug_lookup:
|
||||
Symbol.debug_print("starting point:")
|
||||
print(parentSymbol.to_string(Symbol.debug_indent + 1), end="")
|
||||
logger.debug(parentSymbol.to_string(Symbol.debug_indent + 1), end="")
|
||||
|
||||
# and now the actual lookup
|
||||
for ident in names[:-1]:
|
||||
@ -1837,7 +1837,7 @@ class Symbol:
|
||||
|
||||
if Symbol.debug_lookup:
|
||||
Symbol.debug_print("handle last name from:")
|
||||
print(parentSymbol.to_string(Symbol.debug_indent + 1), end="")
|
||||
logger.debug(parentSymbol.to_string(Symbol.debug_indent + 1), end="")
|
||||
|
||||
# handle the last name
|
||||
ident = names[-1]
|
||||
@ -2088,14 +2088,14 @@ class Symbol:
|
||||
Symbol.debug_print("matchSelf: ", matchSelf)
|
||||
Symbol.debug_print("recurseInAnon: ", recurseInAnon)
|
||||
Symbol.debug_print("searchInSiblings:", searchInSiblings)
|
||||
print(self.to_string(Symbol.debug_indent + 1), end="")
|
||||
logger.debug(self.to_string(Symbol.debug_indent + 1), end="")
|
||||
Symbol.debug_indent -= 2
|
||||
current = self
|
||||
while current is not None:
|
||||
if Symbol.debug_lookup:
|
||||
Symbol.debug_indent += 2
|
||||
Symbol.debug_print("trying:")
|
||||
print(current.to_string(Symbol.debug_indent + 1), end="")
|
||||
logger.debug(current.to_string(Symbol.debug_indent + 1), end="")
|
||||
Symbol.debug_indent -= 2
|
||||
if matchSelf and current.ident == ident:
|
||||
return current
|
||||
@ -2125,7 +2125,7 @@ class Symbol:
|
||||
Symbol.debug_print("name: ", name)
|
||||
Symbol.debug_print("id: ", id_)
|
||||
if s is not None:
|
||||
print(s.to_string(Symbol.debug_indent + 1), end="")
|
||||
logger.debug(s.to_string(Symbol.debug_indent + 1), end="")
|
||||
else:
|
||||
Symbol.debug_print("not found")
|
||||
if s is None:
|
||||
@ -3587,9 +3587,9 @@ class AliasTransform(SphinxTransform):
|
||||
rootSymbol: Symbol = self.env.domains['c'].data['root_symbol']
|
||||
parentSymbol: Symbol = rootSymbol.direct_lookup(parentKey)
|
||||
if not parentSymbol:
|
||||
print("Target: ", sig)
|
||||
print("ParentKey: ", parentKey)
|
||||
print(rootSymbol.dump(1))
|
||||
logger.debug("Target: ", sig)
|
||||
logger.debug("ParentKey: ", parentKey)
|
||||
logger.debug(rootSymbol.dump(1))
|
||||
assert parentSymbol # should be there
|
||||
|
||||
s = parentSymbol.find_declaration(
|
||||
@ -3778,40 +3778,40 @@ class CDomain(Domain):
|
||||
|
||||
def clear_doc(self, docname: str) -> None:
|
||||
if Symbol.debug_show_tree:
|
||||
print("clear_doc:", docname)
|
||||
print("\tbefore:")
|
||||
print(self.data['root_symbol'].dump(1))
|
||||
print("\tbefore end")
|
||||
logger.debug("clear_doc:", docname)
|
||||
logger.debug("\tbefore:")
|
||||
logger.debug(self.data['root_symbol'].dump(1))
|
||||
logger.debug("\tbefore end")
|
||||
|
||||
rootSymbol = self.data['root_symbol']
|
||||
rootSymbol.clear_doc(docname)
|
||||
|
||||
if Symbol.debug_show_tree:
|
||||
print("\tafter:")
|
||||
print(self.data['root_symbol'].dump(1))
|
||||
print("\tafter end")
|
||||
print("clear_doc end:", docname)
|
||||
logger.debug("\tafter:")
|
||||
logger.debug(self.data['root_symbol'].dump(1))
|
||||
logger.debug("\tafter end")
|
||||
logger.debug("clear_doc end:", docname)
|
||||
|
||||
def process_doc(self, env: BuildEnvironment, docname: str,
|
||||
document: nodes.document) -> None:
|
||||
if Symbol.debug_show_tree:
|
||||
print("process_doc:", docname)
|
||||
print(self.data['root_symbol'].dump(0))
|
||||
print("process_doc end:", docname)
|
||||
logger.debug("process_doc:", docname)
|
||||
logger.debug(self.data['root_symbol'].dump(0))
|
||||
logger.debug("process_doc end:", docname)
|
||||
|
||||
def process_field_xref(self, pnode: pending_xref) -> None:
|
||||
pnode.attributes.update(self.env.ref_context)
|
||||
|
||||
def merge_domaindata(self, docnames: list[str], otherdata: dict) -> None:
|
||||
if Symbol.debug_show_tree:
|
||||
print("merge_domaindata:")
|
||||
print("\tself:")
|
||||
print(self.data['root_symbol'].dump(1))
|
||||
print("\tself end")
|
||||
print("\tother:")
|
||||
print(otherdata['root_symbol'].dump(1))
|
||||
print("\tother end")
|
||||
print("merge_domaindata end")
|
||||
logger.debug("merge_domaindata:")
|
||||
logger.debug("\tself:")
|
||||
logger.debug(self.data['root_symbol'].dump(1))
|
||||
logger.debug("\tself end")
|
||||
logger.debug("\tother:")
|
||||
logger.debug(otherdata['root_symbol'].dump(1))
|
||||
logger.debug("\tother end")
|
||||
logger.debug("merge_domaindata end")
|
||||
|
||||
self.data['root_symbol'].merge_with(otherdata['root_symbol'],
|
||||
docnames, self.env)
|
||||
@ -3837,9 +3837,9 @@ class CDomain(Domain):
|
||||
if parentKey:
|
||||
parentSymbol: Symbol = rootSymbol.direct_lookup(parentKey)
|
||||
if not parentSymbol:
|
||||
print("Target: ", target)
|
||||
print("ParentKey: ", parentKey)
|
||||
print(rootSymbol.dump(1))
|
||||
logger.debug("Target: ", target)
|
||||
logger.debug("ParentKey: ", parentKey)
|
||||
logger.debug(rootSymbol.dump(1))
|
||||
assert parentSymbol # should be there
|
||||
else:
|
||||
parentSymbol = rootSymbol
|
||||
|
@ -4242,8 +4242,8 @@ class Symbol:
|
||||
|
||||
@staticmethod
|
||||
def debug_print(*args: Any) -> None:
|
||||
print(Symbol.debug_indent_string * Symbol.debug_indent, end="")
|
||||
print(*args)
|
||||
logger.debug(Symbol.debug_indent_string * Symbol.debug_indent, end="")
|
||||
logger.debug(*args)
|
||||
|
||||
def _assert_invariants(self) -> None:
|
||||
if not self.parent:
|
||||
@ -4452,7 +4452,7 @@ class Symbol:
|
||||
Symbol.debug_print("_find_named_symbols:")
|
||||
Symbol.debug_indent += 1
|
||||
Symbol.debug_print("self:")
|
||||
print(self.to_string(Symbol.debug_indent + 1), end="")
|
||||
logger.debug(self.to_string(Symbol.debug_indent + 1), end="")
|
||||
Symbol.debug_print("identOrOp: ", identOrOp)
|
||||
Symbol.debug_print("templateParams: ", templateParams)
|
||||
Symbol.debug_print("templateArgs: ", templateArgs)
|
||||
@ -4496,7 +4496,7 @@ class Symbol:
|
||||
s = self
|
||||
if Symbol.debug_lookup:
|
||||
Symbol.debug_print("searching in self:")
|
||||
print(s.to_string(Symbol.debug_indent + 1), end="")
|
||||
logger.debug(s.to_string(Symbol.debug_indent + 1), end="")
|
||||
while True:
|
||||
if matchSelf:
|
||||
yield s
|
||||
@ -4510,12 +4510,12 @@ class Symbol:
|
||||
s = s.siblingAbove
|
||||
if Symbol.debug_lookup:
|
||||
Symbol.debug_print("searching in sibling:")
|
||||
print(s.to_string(Symbol.debug_indent + 1), end="")
|
||||
logger.debug(s.to_string(Symbol.debug_indent + 1), end="")
|
||||
|
||||
for s in candidates():
|
||||
if Symbol.debug_lookup:
|
||||
Symbol.debug_print("candidate:")
|
||||
print(s.to_string(Symbol.debug_indent + 1), end="")
|
||||
logger.debug(s.to_string(Symbol.debug_indent + 1), end="")
|
||||
if matches(s):
|
||||
if Symbol.debug_lookup:
|
||||
Symbol.debug_indent += 1
|
||||
@ -4545,7 +4545,7 @@ class Symbol:
|
||||
Symbol.debug_print("_symbol_lookup:")
|
||||
Symbol.debug_indent += 1
|
||||
Symbol.debug_print("self:")
|
||||
print(self.to_string(Symbol.debug_indent + 1), end="")
|
||||
logger.debug(self.to_string(Symbol.debug_indent + 1), end="")
|
||||
Symbol.debug_print("nestedName: ", nestedName)
|
||||
Symbol.debug_print("templateDecls: ", ",".join(str(t) for t in templateDecls))
|
||||
Symbol.debug_print("strictTemplateParamArgLists:", strictTemplateParamArgLists)
|
||||
@ -4592,7 +4592,7 @@ class Symbol:
|
||||
|
||||
if Symbol.debug_lookup:
|
||||
Symbol.debug_print("starting point:")
|
||||
print(parentSymbol.to_string(Symbol.debug_indent + 1), end="")
|
||||
logger.debug(parentSymbol.to_string(Symbol.debug_indent + 1), end="")
|
||||
|
||||
# and now the actual lookup
|
||||
iTemplateDecl = 0
|
||||
@ -4638,7 +4638,7 @@ class Symbol:
|
||||
|
||||
if Symbol.debug_lookup:
|
||||
Symbol.debug_print("handle last name from:")
|
||||
print(parentSymbol.to_string(Symbol.debug_indent + 1), end="")
|
||||
logger.debug(parentSymbol.to_string(Symbol.debug_indent + 1), end="")
|
||||
|
||||
# handle the last name
|
||||
name = names[-1]
|
||||
@ -4997,14 +4997,14 @@ class Symbol:
|
||||
Symbol.debug_print("matchSelf: ", matchSelf)
|
||||
Symbol.debug_print("recurseInAnon: ", recurseInAnon)
|
||||
Symbol.debug_print("searchInSiblings:", searchInSiblings)
|
||||
print(self.to_string(Symbol.debug_indent + 1), end="")
|
||||
logger.debug(self.to_string(Symbol.debug_indent + 1), end="")
|
||||
Symbol.debug_indent -= 2
|
||||
current = self
|
||||
while current is not None:
|
||||
if Symbol.debug_lookup:
|
||||
Symbol.debug_indent += 2
|
||||
Symbol.debug_print("trying:")
|
||||
print(current.to_string(Symbol.debug_indent + 1), end="")
|
||||
logger.debug(current.to_string(Symbol.debug_indent + 1), end="")
|
||||
Symbol.debug_indent -= 2
|
||||
if matchSelf and current.identOrOp == identOrOp:
|
||||
return current
|
||||
@ -5047,7 +5047,7 @@ class Symbol:
|
||||
Symbol.debug_print("templateParams:", templateParams)
|
||||
Symbol.debug_print("id: ", id_)
|
||||
if s is not None:
|
||||
print(s.to_string(Symbol.debug_indent + 1), end="")
|
||||
logger.debug(s.to_string(Symbol.debug_indent + 1), end="")
|
||||
else:
|
||||
Symbol.debug_print("not found")
|
||||
if s is None:
|
||||
@ -5069,7 +5069,7 @@ class Symbol:
|
||||
Symbol.debug_print("find_name:")
|
||||
Symbol.debug_indent += 1
|
||||
Symbol.debug_print("self:")
|
||||
print(self.to_string(Symbol.debug_indent + 1), end="")
|
||||
logger.debug(self.to_string(Symbol.debug_indent + 1), end="")
|
||||
Symbol.debug_print("nestedName: ", nestedName)
|
||||
Symbol.debug_print("templateDecls: ", templateDecls)
|
||||
Symbol.debug_print("typ: ", typ)
|
||||
@ -6916,7 +6916,7 @@ class DefinitionParser(BaseParser):
|
||||
self.fail('Expected "," or ">".')
|
||||
except DefinitionError as e:
|
||||
errs.append((e, "If no parameter"))
|
||||
print(errs)
|
||||
logger.debug(errs)
|
||||
raise self._make_multi_error(errs, header)
|
||||
|
||||
def _parse_template_introduction(self) -> ASTTemplateIntroduction:
|
||||
@ -7717,9 +7717,9 @@ class AliasTransform(SphinxTransform):
|
||||
rootSymbol: Symbol = self.env.domains['cpp'].data['root_symbol']
|
||||
parentSymbol: Symbol = rootSymbol.direct_lookup(parentKey)
|
||||
if not parentSymbol:
|
||||
print("Target: ", sig)
|
||||
print("ParentKey: ", parentKey)
|
||||
print(rootSymbol.dump(1))
|
||||
logger.debug("Target: ", sig)
|
||||
logger.debug("ParentKey: ", parentKey)
|
||||
logger.debug(rootSymbol.dump(1))
|
||||
assert parentSymbol # should be there
|
||||
|
||||
symbols: list[Symbol] = []
|
||||
@ -7960,19 +7960,19 @@ class CPPDomain(Domain):
|
||||
|
||||
def clear_doc(self, docname: str) -> None:
|
||||
if Symbol.debug_show_tree:
|
||||
print("clear_doc:", docname)
|
||||
print("\tbefore:")
|
||||
print(self.data['root_symbol'].dump(1))
|
||||
print("\tbefore end")
|
||||
logger.debug("clear_doc:", docname)
|
||||
logger.debug("\tbefore:")
|
||||
logger.debug(self.data['root_symbol'].dump(1))
|
||||
logger.debug("\tbefore end")
|
||||
|
||||
rootSymbol = self.data['root_symbol']
|
||||
rootSymbol.clear_doc(docname)
|
||||
|
||||
if Symbol.debug_show_tree:
|
||||
print("\tafter:")
|
||||
print(self.data['root_symbol'].dump(1))
|
||||
print("\tafter end")
|
||||
print("clear_doc end:", docname)
|
||||
logger.debug("\tafter:")
|
||||
logger.debug(self.data['root_symbol'].dump(1))
|
||||
logger.debug("\tafter end")
|
||||
logger.debug("clear_doc end:", docname)
|
||||
for name, nDocname in list(self.data['names'].items()):
|
||||
if nDocname == docname:
|
||||
del self.data['names'][name]
|
||||
@ -7980,22 +7980,22 @@ class CPPDomain(Domain):
|
||||
def process_doc(self, env: BuildEnvironment, docname: str,
|
||||
document: nodes.document) -> None:
|
||||
if Symbol.debug_show_tree:
|
||||
print("process_doc:", docname)
|
||||
print(self.data['root_symbol'].dump(0))
|
||||
print("process_doc end:", docname)
|
||||
logger.debug("process_doc:", docname)
|
||||
logger.debug(self.data['root_symbol'].dump(0))
|
||||
logger.debug("process_doc end:", docname)
|
||||
|
||||
def process_field_xref(self, pnode: pending_xref) -> None:
|
||||
pnode.attributes.update(self.env.ref_context)
|
||||
|
||||
def merge_domaindata(self, docnames: list[str], otherdata: dict) -> None:
|
||||
if Symbol.debug_show_tree:
|
||||
print("merge_domaindata:")
|
||||
print("\tself:")
|
||||
print(self.data['root_symbol'].dump(1))
|
||||
print("\tself end")
|
||||
print("\tother:")
|
||||
print(otherdata['root_symbol'].dump(1))
|
||||
print("\tother end")
|
||||
logger.debug("merge_domaindata:")
|
||||
logger.debug("\tself:")
|
||||
logger.debug(self.data['root_symbol'].dump(1))
|
||||
logger.debug("\tself end")
|
||||
logger.debug("\tother:")
|
||||
logger.debug(otherdata['root_symbol'].dump(1))
|
||||
logger.debug("\tother end")
|
||||
|
||||
self.data['root_symbol'].merge_with(otherdata['root_symbol'],
|
||||
docnames, self.env)
|
||||
@ -8006,10 +8006,10 @@ class CPPDomain(Domain):
|
||||
ourNames[name] = docname
|
||||
# no need to warn on duplicates, the symbol merge already does that
|
||||
if Symbol.debug_show_tree:
|
||||
print("\tresult:")
|
||||
print(self.data['root_symbol'].dump(1))
|
||||
print("\tresult end")
|
||||
print("merge_domaindata end")
|
||||
logger.debug("\tresult:")
|
||||
logger.debug(self.data['root_symbol'].dump(1))
|
||||
logger.debug("\tresult end")
|
||||
logger.debug("merge_domaindata end")
|
||||
|
||||
def _resolve_xref_inner(self, env: BuildEnvironment, fromdocname: str, builder: Builder,
|
||||
typ: str, target: str, node: pending_xref,
|
||||
@ -8044,9 +8044,9 @@ class CPPDomain(Domain):
|
||||
if parentKey:
|
||||
parentSymbol: Symbol = rootSymbol.direct_lookup(parentKey)
|
||||
if not parentSymbol:
|
||||
print("Target: ", target)
|
||||
print("ParentKey: ", parentKey.data)
|
||||
print(rootSymbol.dump(1))
|
||||
logger.debug("Target: ", target)
|
||||
logger.debug("ParentKey: ", parentKey.data)
|
||||
logger.debug(rootSymbol.dump(1))
|
||||
assert parentSymbol # should be there
|
||||
else:
|
||||
parentSymbol = rootSymbol
|
||||
@ -8099,7 +8099,7 @@ class CPPDomain(Domain):
|
||||
objtypes = self.objtypes_for_role(typ)
|
||||
if objtypes:
|
||||
return declTyp in objtypes
|
||||
print(f"Type is {typ}, declaration type is {declTyp}")
|
||||
logger.debug(f"Type is {typ}, declaration type is {declTyp}")
|
||||
raise AssertionError
|
||||
if not checkType():
|
||||
logger.warning("cpp:%s targets a %s (%s).",
|
||||
|
@ -27,12 +27,15 @@ import sphinx.locale
|
||||
from sphinx import __display_version__, package_dir
|
||||
from sphinx.cmd.quickstart import EXTENSIONS
|
||||
from sphinx.locale import __
|
||||
from sphinx.util import logging
|
||||
from sphinx.util.osutil import FileAvoidWrite, ensuredir
|
||||
from sphinx.util.template import ReSTRenderer
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from collections.abc import Generator, Sequence
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
# automodule options
|
||||
if 'SPHINX_APIDOC_OPTIONS' in os.environ:
|
||||
OPTIONS = os.environ['SPHINX_APIDOC_OPTIONS'].split(',')
|
||||
@ -80,14 +83,14 @@ def write_file(name: str, text: str, opts: Any) -> None:
|
||||
fname = path.join(opts.destdir, f'{name}.{opts.suffix}')
|
||||
if opts.dryrun:
|
||||
if not quiet:
|
||||
print(__('Would create file %s.') % fname)
|
||||
logger.info(__('Would create file %s.'), fname)
|
||||
return
|
||||
if not opts.force and path.isfile(fname):
|
||||
if not quiet:
|
||||
print(__('File %s already exists, skipping.') % fname)
|
||||
logger.info(__('File %s already exists, skipping.'), fname)
|
||||
else:
|
||||
if not quiet:
|
||||
print(__('Creating file %s.') % fname)
|
||||
logger.info(__('Creating file %s.'), fname)
|
||||
with FileAvoidWrite(fname) as f:
|
||||
f.write(text)
|
||||
|
||||
@ -423,7 +426,7 @@ def main(argv: list[str] = sys.argv[1:]) -> int:
|
||||
if args.suffix.startswith('.'):
|
||||
args.suffix = args.suffix[1:]
|
||||
if not path.isdir(rootpath):
|
||||
print(__('%s is not a directory.') % rootpath, file=sys.stderr)
|
||||
logger.error(__('%s is not a directory.'), rootpath)
|
||||
raise SystemExit(1)
|
||||
if not args.dryrun:
|
||||
ensuredir(args.destdir)
|
||||
|
@ -580,10 +580,10 @@ def find_autosummary_in_docstring(
|
||||
pass
|
||||
except ImportExceptionGroup as exc:
|
||||
errors = '\n'.join({f"* {type(e).__name__}: {e}" for e in exc.exceptions})
|
||||
print(f'Failed to import {name}.\nPossible hints:\n{errors}')
|
||||
logger.warning(f'Failed to import {name}.\nPossible hints:\n{errors}') # NoQA: G004
|
||||
except SystemExit:
|
||||
print("Failed to import '%s'; the module executes module level "
|
||||
"statement and it might call sys.exit()." % name)
|
||||
logger.warning("Failed to import '%s'; the module executes module level "
|
||||
'statement and it might call sys.exit().', name)
|
||||
return []
|
||||
|
||||
|
||||
|
@ -284,7 +284,7 @@ class BaseParser:
|
||||
def status(self, msg: str) -> None:
|
||||
# for debugging
|
||||
indicator = '-' * self.pos + '^'
|
||||
print(f"{msg}\n{self.definition}\n{indicator}")
|
||||
logger.debug(f"{msg}\n{self.definition}\n{indicator}") # NoQA: G004
|
||||
|
||||
def fail(self, msg: str) -> None:
|
||||
errors = []
|
||||
|
Loading…
Reference in New Issue
Block a user