argparse errors?

33 views
Skip to first unread message

Boyan Penkov

unread,
Jul 26, 2023, 6:16:29 PM7/26/23
to sphinx-users
Hello folks,

I'm writing to ask if folks have seen the following argparse errors:

```
# Platform:         linux; (Linux-6.1.0-9-amd64-x86_64-with-glibc2.36)
# Sphinx version:   7.0.1
# Python version:   3.10.12 (CPython)
# Docutils version: 0.20.1
# Jinja2 version:   3.1.2
# Pygments version: 2.15.1

# Last messages:
#   done
#   [autosummary] generating autosummary for: index.rst
#   building [mo]: targets for 0 po files that are out of date
#   writing output...
#  
#   building [coverage]: coverage overview
#   updating environment:
#   [new config]
#   1 added, 0 changed, 0 removed
#   reading sources... [100%] index

# Loaded extensions:
#   sphinx.ext.mathjax (7.0.1)
#   alabaster (0.7.13)
#   sphinxcontrib.applehelp (1.0.4)
#   sphinxcontrib.devhelp (1.0.2)
#   sphinxcontrib.htmlhelp (2.0.1)
#   sphinxcontrib.serializinghtml (1.1.5)
#   sphinxcontrib.qthelp (1.0.3)
#   sphinx.ext.autodoc.preserve_defaults (7.0.1)
#   sphinx.ext.autodoc.type_comment (7.0.1)
#   sphinx.ext.autodoc.typehints (7.0.1)
#   sphinx.ext.autodoc (7.0.1)
#   sphinx.ext.autosummary (7.0.1)
#   numpydoc (1.5.0)
#   sphinx.ext.coverage (7.0.1)
#   sphinxarg.ext (0.2.5)
#   m2r2 (0.3.3.post2)

# Traceback:
Traceback (most recent call last):
  File "/home/boyan/miniconda3/envs/py310/lib/python3.10/site-packages/sphinx/cmd/build.py", line 285, in build_main
    app.build(args.force_all, args.filenames)
  File "/home/boyan/miniconda3/envs/py310/lib/python3.10/site-packages/sphinx/application.py", line 351, in build
    self.builder.build_update()
  File "/home/boyan/miniconda3/envs/py310/lib/python3.10/site-packages/sphinx/builders/__init__.py", line 291, in build_update
    self.build(['__all__'], to_build)
  File "/home/boyan/miniconda3/envs/py310/lib/python3.10/site-packages/sphinx/builders/__init__.py", line 311, in build
    updated_docnames = set(self.read())
  File "/home/boyan/miniconda3/envs/py310/lib/python3.10/site-packages/sphinx/builders/__init__.py", line 418, in read
    self._read_serial(docnames)
  File "/home/boyan/miniconda3/envs/py310/lib/python3.10/site-packages/sphinx/builders/__init__.py", line 439, in _read_serial
    self.read_doc(docname)
  File "/home/boyan/miniconda3/envs/py310/lib/python3.10/site-packages/sphinx/builders/__init__.py", line 495, in read_doc
    publisher.publish()
  File "/home/boyan/miniconda3/envs/py310/lib/python3.10/site-packages/docutils/core.py", line 234, in publish
    self.document = self.reader.read(self.source, self.parser,
  File "/home/boyan/miniconda3/envs/py310/lib/python3.10/site-packages/sphinx/io.py", line 104, in read
    self.parse()
  File "/home/boyan/miniconda3/envs/py310/lib/python3.10/site-packages/docutils/readers/__init__.py", line 76, in parse
    self.parser.parse(self.input, document)
  File "/home/boyan/miniconda3/envs/py310/lib/python3.10/site-packages/sphinx/parsers.py", line 80, in parse
    self.statemachine.run(inputlines, document, inliner=self.inliner)
  File "/home/boyan/miniconda3/envs/py310/lib/python3.10/site-packages/docutils/parsers/rst/states.py", line 169, in run
    results = StateMachineWS.run(self, input_lines, input_offset,
  File "/home/boyan/miniconda3/envs/py310/lib/python3.10/site-packages/docutils/statemachine.py", line 233, in run
    context, next_state, result = self.check_line(
  File "/home/boyan/miniconda3/envs/py310/lib/python3.10/site-packages/docutils/statemachine.py", line 445, in check_line
    return method(match, context, next_state)
  File "/home/boyan/miniconda3/envs/py310/lib/python3.10/site-packages/docutils/parsers/rst/states.py", line 2785, in underline
    self.section(title, source, style, lineno - 1, messages)
  File "/home/boyan/miniconda3/envs/py310/lib/python3.10/site-packages/docutils/parsers/rst/states.py", line 325, in section
    self.new_subsection(title, lineno, messages)
  File "/home/boyan/miniconda3/envs/py310/lib/python3.10/site-packages/docutils/parsers/rst/states.py", line 391, in new_subsection
    newabsoffset = self.nested_parse(
  File "/home/boyan/miniconda3/envs/py310/lib/python3.10/site-packages/docutils/parsers/rst/states.py", line 279, in nested_parse
    state_machine.run(block, input_offset, memo=self.memo,
  File "/home/boyan/miniconda3/envs/py310/lib/python3.10/site-packages/docutils/parsers/rst/states.py", line 195, in run
    results = StateMachineWS.run(self, input_lines, input_offset)
  File "/home/boyan/miniconda3/envs/py310/lib/python3.10/site-packages/docutils/statemachine.py", line 233, in run
    context, next_state, result = self.check_line(
  File "/home/boyan/miniconda3/envs/py310/lib/python3.10/site-packages/docutils/statemachine.py", line 445, in check_line
    return method(match, context, next_state)
  File "/home/boyan/miniconda3/envs/py310/lib/python3.10/site-packages/docutils/parsers/rst/states.py", line 2355, in explicit_markup
    nodelist, blank_finish = self.explicit_construct(match)
  File "/home/boyan/miniconda3/envs/py310/lib/python3.10/site-packages/docutils/parsers/rst/states.py", line 2367, in explicit_construct
    return method(self, expmatch)
  File "/home/boyan/miniconda3/envs/py310/lib/python3.10/site-packages/docutils/parsers/rst/states.py", line 2104, in directive
    return self.run_directive(
  File "/home/boyan/miniconda3/envs/py310/lib/python3.10/site-packages/docutils/parsers/rst/states.py", line 2154, in run_directive
    result = directive_instance.run()
  File "/home/boyan/miniconda3/envs/py310/lib/python3.10/site-packages/sphinxarg/ext.py", line 464, in run
    f = self._open_filename()
  File "/home/boyan/miniconda3/envs/py310/lib/python3.10/site-packages/sphinxarg/ext.py", line 448, in _open_filename
    return open(shutil.which(self.options['filename']))
TypeError: expected str, bytes or os.PathLike object, not NoneType

```

Anybody have a suggestion here?

Cheers!

Mats Wichmann

unread,
Jul 26, 2023, 7:41:30 PM7/26/23
to sphinx...@googlegroups.com
Not directly, but this is a really classic Python error:

TypeError: expected str, bytes or os.PathLike object, not NoneTyp

it means something returned None when the caller wasn't expecting None.  shutil.which returns None if it could't find any matches for the thing it was asked to look up.

--
You received this message because you are subscribed to the Google Groups "sphinx-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sphinx-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sphinx-users/c44efdfc-3e9a-4dca-b854-4c097189b5ccn%40googlegroups.com.

Boyan Penkov

unread,
Jul 27, 2023, 5:00:37 AM7/27/23
to sphinx-users
Hey Mats -- thanks, that's clear...

The question is why does this come up in released code?  The same error does not occur in the conda argparse running under Sphinx 6.1.3, running under python3.9.

Cheers!

Boyan Penkov

unread,
Jul 27, 2023, 11:29:43 AM7/27/23
to sphinx-users
Strangely, works under sphinx 6.1.3 but not under 7.0.1, both with argparse 0.4.0
Reply all
Reply to author
Forward
0 new messages