module documentation

Emacs and Flymake compatible Pylint. This script is for integration with Emacs and is compatible with Flymake mode. epylint walks out of python packages before invoking pylint. This avoids reporting import errors that occur when a module within a package uses the absolute import path to get another module within this package. For example: - Suppose a package is structured as a/__init__.py a/b/x.py a/c/y.py - Then if y.py imports x as "from a.b import x" the following produces pylint errors cd a/c; pylint y.py - The following obviously doesn't pylint a/c/y.py - As this script will be invoked by Emacs within the directory of the file we are checking we need to go out of it to avoid these false positives. You may also use py_run to run pylint with desired options and get back (or not) its output.

Function lint Pylint the given file.
Function py_run Run pylint from python.
Function Run Undocumented
Function _get_env Extracts the environment PYTHONPATH and appends the current 'sys.path' to it.
def lint(filename: str, options: Sequence[str] = ()) -> int: (source)

Pylint the given file. When run from Emacs we will be in the directory of a file, and passed its filename. If this file is part of a package and is trying to import other modules from within its own package or another package rooted in a directory below it, pylint will classify it as a failed import. To get around this, we traverse down the directory tree to find the root of the package this module is in. We then invoke pylint from this directory. Finally, we must correct the filenames in the output generated by pylint so Emacs doesn't become confused (it will expect just the original filename, while pylint may extend it with extra directories if we've traversed down the tree)

@overload
def py_run(command_options: str = ..., return_std: Literal[False] = ..., stdout: (TextIO|int)|None = ..., stderr: (TextIO|int)|None = ...):
@overload
def py_run(command_options: str, return_std: Literal[True], stdout: (TextIO|int)|None = ..., stderr: (TextIO|int)|None = ...) -> tuple[StringIO, StringIO]:
(source)

Run pylint from python. ``command_options`` is a string containing ``pylint`` command line options; ``return_std`` (boolean) indicates return of created standard output and error (see below); ``stdout`` and ``stderr`` are 'file-like' objects in which standard output could be written. Calling agent is responsible for stdout/err management (creation, close). Default standard output and error are those from sys, or standalone ones (``subprocess.PIPE``) are used if they are not set and ``return_std``. If ``return_std`` is set to ``True``, this function returns a 2-uple containing standard output and error related to created process, as follows: ``(stdout, stderr)``. To silently run Pylint on a module, and get its standard output and error: >>> (pylint_stdout, pylint_stderr) = py_run( 'module_name.py', True)

Undocumented

def _get_env() -> dict[str, str]: (source)

Extracts the environment PYTHONPATH and appends the current 'sys.path' to it.