Path 1: 2 calls (1.0)

"/private/var/folders/yp/qx0crmvd4sbck7chb52sws500000gn/T/pytest-of-andrehora/pytest-178/test_epylint_good_command0/my_app.py -E --disable=E1111 --msg...

True (2)

None (2)

None (2)

1def py_run(
2    command_options: str = "",
3    return_std: bool = False,
4    stdout: TextIO | int | None = None,
5    stderr: TextIO | int | None = None,
6) -> tuple[StringIO, StringIO] | None:
7    """Run pylint from python.
8
9    ``command_options`` is a string containing ``pylint`` command line options;
10    ``return_std`` (boolean) indicates return of created standard output
11    and error (see below);
12    ``stdout`` and ``stderr`` are 'file-like' objects in which standard output
13    could be written.
14
15    Calling agent is responsible for stdout/err management (creation, close).
16    Default standard output and error are those from sys,
17    or standalone ones (``subprocess.PIPE``) are used
18    if they are not set and ``return_std``.
19
20    If ``return_std`` is set to ``True``, this function returns a 2-uple
21    containing standard output and error related to created process,
22    as follows: ``(stdout, stderr)``.
23
24    To silently run Pylint on a module, and get its standard output and error:
25        >>> (pylint_stdout, pylint_stderr) = py_run( 'module_name.py', True)
26    """
27    warnings.warn(
28        "'epylint' will be removed in pylint 3.0, use https://github.com/emacsorphanage/pylint instead.",
29        DeprecationWarning,
30        stacklevel=2,
31    )
32    # Detect if we use Python as executable or not, else default to `python`
33    executable = sys.executable if "python" in sys.executable else "python"
34
35    # Create command line to call pylint
36    epylint_part = [executable, "-c", "from pylint import epylint;epylint.Run()"]
37    options = shlex.split(command_options, posix=not sys.platform.startswith("win"))
38    cli = epylint_part + options
39
40    # Providing standard output and/or error if not set
41    if stdout is None:
42        stdout = PIPE if return_std else sys.stdout
43    if stderr is None:
44        stderr = PIPE if return_std else sys.stderr
45    # Call pylint in a sub-process
46    with Popen(
47        cli,
48        shell=False,
49        stdout=stdout,
50        stderr=stderr,
51        env=_get_env(),
52        universal_newlines=True,
53    ) as process:
54        proc_stdout, proc_stderr = process.communicate()
55        # Return standard output and error
56        if return_std:
57            return StringIO(proc_stdout), StringIO(proc_stderr)
58        return None