Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[low-prio] Possible bug: files without extensions misidentified as Python? #1488

Open
jayaddison opened this issue Nov 16, 2022 · 4 comments · May be fixed by #1489
Open

[low-prio] Possible bug: files without extensions misidentified as Python? #1488

jayaddison opened this issue Nov 16, 2022 · 4 comments · May be fixed by #1489
Labels
bug Something isn't working

Comments

@jayaddison
Copy link

Describe the bug
While running pytest with coverage (v6.5.0) for sphinx, I noticed an unusual warning in the output logs:

sphinx/venv/lib/python3.10/site-packages/coverage/report.py:81: CoverageWarning: Couldn't parse Python file '/home/jka/Documents/personal/sphinx/sphinx/templates/quickstart/Makefile_t' (couldnt-parse)
  coverage._warn(msg, slug="couldnt-parse")

Digging into the code to figure out where that's coming from, I found this conditional block:

# A file with no extension should be Python.
if not ext:
return True

To Reproduce
How can we reproduce the problem? Please be specific. Don't link to a failing CI job. Answer the questions below:

  1. What version of Python are you using? 3.10
  2. What version of coverage.py shows the problem? 6.5.0
  3. What code shows the problem? sphinx-doc/sphinx@cd3f2e4
  4. What commands did you run? pytest --cov=sphinx --cov-config=setup.cfg

Expected behavior
No warning should appear.

Additional context
I realize that perhaps there could be input types / environments where files don't have extensions that have been supported for historic reasons - and I've read some of the context in #82. Even so it seems like maybe the file shouldn't be considered Python-y.

@nedbat
Copy link
Owner

nedbat commented Dec 2, 2022

Interesting... Jinja is templating the files, and using the template name as the "Python" file name when running the resulting Python code.

You can run this with a simpler command and look at the data collected:

% coverage run -m pytest -k test_quickstart_defaults
====================================================================== test session starts =======================================================================
platform darwin -- Python 3.10.8, pytest-7.2.0, pluggy-1.0.0
libraries: Sphinx-6.0.0b3+/cd3f2e435, docutils-0.19
base tempdir: /private/var/folders/10/4sn2sk3j2mg5m116f08_367m0000gq/T/pytest-of-nedbatchelder/pytest-1103
rootdir: /System/Volumes/Data/root/src/bugs/bug1488/sphinx, configfile: pyproject.toml, testpaths: tests
plugins: cov-4.0.0
collected 1842 items / 1841 deselected / 1 selected

tests/test_quickstart.py .                                                                                                                                 [100%]

======================================================================== warnings summary ========================================================================
sphinx/ext/napoleon/iterators.py:9
  /System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/ext/napoleon/iterators.py:9: RemovedInSphinx70Warning: sphinx.ext.napoleon.iterators is deprecated.
    warnings.warn('sphinx.ext.napoleon.iterators is deprecated.',

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
========================================================= 1 passed, 1841 deselected, 1 warning in 1.68s ==========================================================

% coverage combine
Combined data file .coverage.C02DR1CCMD6V.26744.812946

% coverage debug data
-- data ------------------------------------------------------
path: /System/Volumes/Data/root/src/bugs/bug1488/sphinx/.coverage
has_arcs: True
174 files:
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/__init__.py: 30 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/__main__.py: 0 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/addnodes.py: 161 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/application.py: 130 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/builders/__init__.py: 80 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/builders/_epub_base.py: 0 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/builders/changes.py: 0 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/builders/dirhtml.py: 14 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/builders/dummy.py: 17 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/builders/epub3.py: 0 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/builders/gettext.py: 79 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/builders/html/__init__.py: 179 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/builders/html/transforms.py: 16 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/builders/latex/__init__.py: 112 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/builders/latex/constants.py: 108 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/builders/latex/nodes.py: 23 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/builders/latex/theming.py: 30 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/builders/latex/transforms.py: 0 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/builders/latex/util.py: 10 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/builders/linkcheck.py: 85 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/builders/manpage.py: 32 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/builders/singlehtml.py: 32 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/builders/texinfo.py: 46 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/builders/text.py: 0 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/builders/xml.py: 0 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/cmd/__init__.py: 1 line
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/cmd/build.py: 0 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/cmd/make_mode.py: 0 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/cmd/quickstart.py: 223 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/config.py: 128 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/deprecation.py: 36 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/directives/__init__.py: 57 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/directives/code.py: 107 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/directives/other.py: 0 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/directives/patches.py: 0 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/domains/__init__.py: 73 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/domains/c.py: 648 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/domains/changeset.py: 0 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/domains/citation.py: 0 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/domains/cpp.py: 1330 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/domains/index.py: 35 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/domains/javascript.py: 119 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/domains/math.py: 46 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/domains/python.py: 287 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/domains/rst.py: 81 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/domains/std.py: 205 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/environment/__init__.py: 101 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/environment/adapters/__init__.py: 1 line
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/environment/adapters/asset.py: 5 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/environment/adapters/indexentries.py: 17 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/environment/adapters/toctree.py: 23 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/environment/collectors/__init__.py: 17 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/environment/collectors/asset.py: 0 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/environment/collectors/dependencies.py: 0 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/environment/collectors/metadata.py: 0 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/environment/collectors/title.py: 0 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/environment/collectors/toctree.py: 0 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/errors.py: 49 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/events.py: 40 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/ext/__init__.py: 1 line
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/ext/apidoc.py: 44 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/ext/autodoc/__init__.py: 356 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/ext/autodoc/directive.py: 35 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/ext/autodoc/importer.py: 25 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/ext/autodoc/mock.py: 52 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/ext/autodoc/preserve_defaults.py: 0 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/ext/autodoc/type_comment.py: 0 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/ext/autodoc/typehints.py: 0 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/ext/autosectionlabel.py: 0 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/ext/autosummary/__init__.py: 95 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/ext/autosummary/generate.py: 71 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/ext/coverage.py: 0 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/ext/doctest.py: 96 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/ext/duration.py: 0 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/ext/extlinks.py: 0 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/ext/githubpages.py: 0 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/ext/graphviz.py: 89 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/ext/ifconfig.py: 0 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/ext/imgconverter.py: 0 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/ext/imgmath.py: 0 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/ext/inheritance_diagram.py: 84 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/ext/intersphinx.py: 99 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/ext/linkcode.py: 0 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/ext/mathjax.py: 18 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/ext/napoleon/__init__.py: 32 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/ext/napoleon/docstring.py: 125 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/ext/napoleon/iterators.py: 20 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/ext/todo.py: 0 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/ext/viewcode.py: 0 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/extension.py: 13 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/highlighting.py: 40 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/io.py: 51 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/jinja2glue.py: 51 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/locale/__init__.py: 79 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/parsers.py: 24 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/project.py: 18 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/pycode/__init__.py: 34 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/pycode/ast.py: 54 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/pycode/parser.py: 72 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/pygments_styles.py: 60 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/registry.py: 105 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/roles.py: 93 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/search/__init__.py: 82 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/search/da.py: 0 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/search/de.py: 0 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/search/en.py: 14 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/search/es.py: 0 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/search/fi.py: 0 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/search/fr.py: 0 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/search/hu.py: 0 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/search/it.py: 0 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/search/ja.py: 0 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/search/nl.py: 0 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/search/no.py: 0 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/search/pt.py: 0 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/search/ro.py: 0 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/search/ru.py: 0 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/search/sv.py: 0 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/search/tr.py: 0 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/search/zh.py: 0 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/setup_command.py: 0 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/templates/quickstart/Makefile_t: 18 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/templates/quickstart/make.bat_t: 18 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/templates/quickstart/root_doc.rst_t: 29 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/testing/__init__.py: 1 line
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/testing/comparer.py: 15 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/testing/fixtures.py: 49 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/testing/path.py: 46 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/testing/restructuredtext.py: 8 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/testing/util.py: 54 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/theming.py: 40 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/transforms/__init__.py: 108 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/transforms/compact_bullet_list.py: 0 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/transforms/i18n.py: 38 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/transforms/post_transforms/__init__.py: 47 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/transforms/post_transforms/code.py: 0 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/transforms/post_transforms/images.py: 0 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/transforms/references.py: 13 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/util/__init__.py: 94 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/util/build_phase.py: 9 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/util/cfamily.py: 100 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/util/console.py: 50 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/util/docfields.py: 66 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/util/docstrings.py: 9 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/util/docutils.py: 141 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/util/fileutil.py: 14 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/util/i18n.py: 83 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/util/images.py: 23 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/util/inspect.py: 91 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/util/inventory.py: 27 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/util/jsdump.py: 0 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/util/logging.py: 133 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/util/matching.py: 38 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/util/math.py: 6 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/util/nodes.py: 115 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/util/osutil.py: 42 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/util/parallel.py: 31 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/util/png.py: 0 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/util/requests.py: 17 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/util/rst.py: 29 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/util/stemmer/__init__.py: 0 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/util/tags.py: 17 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/util/template.py: 50 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/util/texescape.py: 15 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/util/typing.py: 29 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/versioning.py: 24 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/writers/__init__.py: 1 line
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/writers/html5.py: 143 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/writers/html.py: 153 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/writers/latex.py: 326 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/writers/manpage.py: 105 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/writers/texinfo.py: 299 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/writers/text.py: 272 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/writers/xml.py: 0 lines

Notice the lines:

/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/templates/quickstart/Makefile_t: 18 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/templates/quickstart/make.bat_t: 18 lines
/System/Volumes/Data/root/src/bugs/bug1488/sphinx/sphinx/templates/quickstart/root_doc.rst_t: 29 lines

These are not Python files, but Jinja is turning them into Python code and using the original file name. The second and third files are ignored because their file extension excludes them. The first is considered a possible Python file because coverage.py wants to allow extensionless files being used as scripts.

I'm not sure if there's a way to keep that behavior and also not pester you with warnings.

@jayaddison
Copy link
Author

These are not Python files, but Jinja is turning them into Python code and using the original file name. The second and third files are ignored because their file extension excludes them.

That makes sense, thanks!

I briefly wondered whether it'd be possible to test those extensionless-script files for a first-line starting with #! that includes the string /python.. but I suppose it's not guaranteed that the files will even be text files (also, this warning doesn't seem hugely noisy).

@jayaddison
Copy link
Author

I'm thinking about closing this issue, although also considering what changes would be required to reduce these warnings.

The best alternative to doing-nothing here (which would probably be fine) that I can think of would be:

  • Rename the Jinja template files in Sphinx to use an identifying file extension (perhaps .jinja or .j2 -- it seems unclear whether there's a standard for this, although I prefer the former, to be honest, because it seems less ambiguous)
  • Teach coveragepy that the chosen file extension is also a file that may contain Python code

One factor that I don't yet completely understand is: would coveragepy report correctly on the code coverage achieved within those templates? (it is totally valid to want to achieve code test coverage for templates; what's unclear to me is whether that already works)

Another relevant factor is that adding that new extension would affect not only the sphinx codebase, but also many other codebases that coveragepy is used for. Maybe that'd be positive, but any change has the potential for disruption, and if the value of the change isn't worth maintainer time, then it may not be worth doing in the first place.

@jayaddison
Copy link
Author

@nedbat what do you think about adding .jinja as a file extension that should_be_python considers as potentially containing Python code for coverage reporting purposes?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
2 participants