You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It appears that (binary!) imports from markupsafe._speedups have side-effects in a pylint invocation. The file that is linted attempts to import a missing package in a try-except clause. A common invocation of pylint produces empty (plug-in) reports if markupsafe is imported before pylint is linting (e.g. imported by a pylint plugin). However, output is produced as expected if either:
the missing import is installed; or
the try block is replaced by a non-import statement (e.g. raise ValueError); or
markupsafe.__init__ is modified to prefer imports from markupsafe._native; or
one imports a Cython package, e.g. ormsgpack, instead of markupsafe.
The first two observations may help in determining the root issue, but are not the problem themselves. The second two observations are what made me report the issue at MarkupSafe, as that suggests that the issue is specific to this package. However: I don't know where the root cause is, so I'm submitting this issue to both MarkupSafe and Pylint and trust that the community has a more complete understanding of the powers at play.
I have two files in the same directory: invoke_pytest.py and my_module.py
# invoke_pytest.pyimportmarkupsafe# this import is not used -- it can only contribute side-effects or invoke pylint side-effects!frompylintimportrun_pylintrun_pylint(
argv=[
"--output-format=pylint_junit.JUnitReporter:pylint-report.xml",
"my_module.py",
]
)
I have a virtual environment in which I installed pylint pylint-junit markupsafe. pylint-junit is merely needed to show that a pylint plugin becomes unable to produce output. The issue surfaced originally in pylint-gitlab, which has markupdown as a dependency through jinja2.
$ python invoke_pytest.py; head pylint-report.xml
Expected output
After commenting import markupsafe from invoke_pytest.py, the output is as expected:
$ python invoke_pytest.py; head pylint-report.xml
<?xml version="1.0"?><testsuites disabled="0" errors="0" failures="2" tests="4" time="0.0"><testsuite disabled="0" errors="0" failures="0" name="Command line or configuration file" skipped="0" tests="1" time="0"><testcase name="Command line or configuration file:0:0" classname="pylint"><system-out>All checks passed for: None</system-out></testcase></testsuite><testsuite disabled="0" errors="0" failures="2" name="my_module" skipped="0" tests="3" time="0"><testcase name="my_module:0:0" classname="pylint" file="my_module.py"><system-out>All checks passed for: my_module.py</system-out>
As mentioned above, the same output is achieved if markupsafe.__init__ is adjusted to not import from ._speedups.
I understand that the example is not quite minimal yet -- there is a lot of pylint stuff under the hood. Again, let me emphasize that I reach out to both communities and I hope to jointly reduce the example shortly.
I want to finish this report by stating that I appreciate all your efforts, keep up the good work!
The text was updated successfully, but these errors were encountered:
I have absolutely no idea why this happens, or how to debug it. It sounds like it's an issue with how pylint collects information, but I also have no experience with pylint. We're doing the most basic extension possible, defining a few methods. If that's an issue, then it's an issue with CPython or with pylint.
Description
It appears that (binary!) imports from
markupsafe._speedups
have side-effects in apylint
invocation. The file that is linted attempts to import a missing package in atry-except
clause. A common invocation ofpylint
produces empty (plug-in) reports ifmarkupsafe
is imported before pylint is linting (e.g. imported by a pylint plugin). However, output is produced as expected if either:try
block is replaced by a non-import statement (e.g.raise ValueError
); ormarkupsafe.__init__
is modified to prefer imports frommarkupsafe._native
; orormsgpack
, instead ofmarkupsafe
.The first two observations may help in determining the root issue, but are not the problem themselves. The second two observations are what made me report the issue at
MarkupSafe
, as that suggests that the issue is specific to this package. However: I don't know where the root cause is, so I'm submitting this issue to both MarkupSafe and Pylint and trust that the community has a more complete understanding of the powers at play.The issue at
Pylint
(copy of this issue): pylint-dev/pylint#8026.This issue lies at the root of https://gitlab.com/smueller18/pylint-gitlab/-/issues/18.
Setup
I have two files in the same directory:
invoke_pytest.py
andmy_module.py
I have a virtual environment in which I installed
pylint pylint-junit markupsafe
.pylint-junit
is merely needed to show that a pylint plugin becomes unable to produce output. The issue surfaced originally inpylint-gitlab
, which hasmarkupdown
as a dependency throughjinja2
.$ python invoke_pytest.py; head pylint-report.xml
Expected output
After commenting
import markupsafe
frominvoke_pytest.py
, the output is as expected:As mentioned above, the same output is achieved if
markupsafe.__init__
is adjusted to not import from._speedups
.Environment
Windows 10 -> WSL2 -> Ubuntu
I understand that the example is not quite minimal yet -- there is a lot of pylint stuff under the hood. Again, let me emphasize that I reach out to both communities and I hope to jointly reduce the example shortly.
I want to finish this report by stating that I appreciate all your efforts, keep up the good work!
The text was updated successfully, but these errors were encountered: