Type stubs for pyflakes, a Python source code analysis tool designed to detect errors in Python files
npx @tessl/cli install tessl/pypi-types--pyflakes@2.5.0Type stubs for pyflakes, a Python source code analysis tool that detects errors in Python files without importing them. These type stubs enable static type checking for pyflakes functionality, supporting code linting tools, IDEs, and development workflows that require precise type information for pyflakes APIs.
pip install types-pyflakesimport pyflakes
from pyflakes import api
from pyflakes.checker import Checker
from pyflakes.messages import Message
from pyflakes.reporter import Reporter
# Access version information
print(pyflakes.__version__)For checking code:
from pyflakes.api import check, checkPath, checkRecursiveFor custom analysis:
from pyflakes.checker import Checker
from pyflakes.reporter import Reporterfrom pyflakes.api import check
from pyflakes.reporter import Reporter
import sys
# Check a code string
code = """
import os
import sys # This will trigger UnusedImport
print("Hello world")
"""
# Create a reporter for output
reporter = Reporter(sys.stderr, sys.stderr)
# Check the code
result = check(code, "example.py", reporter)
print(f"Found {result} issues")
# Check a file
from pyflakes.api import checkPath
result = checkPath("myfile.py", reporter)Pyflakes operates through a multi-stage analysis pipeline:
pyflakes.api): High-level functions for checking code strings, files, and directoriespyflakes.checker): Core AST analysis engine with sophisticated scope and binding managementpyflakes.messages): Comprehensive error and warning message classes for different issue typespyflakes.reporter): Configurable output system for displaying analysis resultsThe checker performs static analysis by parsing Python code into Abstract Syntax Trees (AST), tracking variable bindings across scopes, and identifying issues like unused imports, undefined names, and syntax errors without executing the code.
High-level functions for checking Python code strings, individual files, and entire directory trees. Supports both simple error detection and custom reporting workflows.
def check(codeString: str, filename: str, reporter: Reporter | None = ...) -> int: ...
def checkPath(filename, reporter: Reporter | None = ...) -> int: ...
def checkRecursive(paths: Iterable[Any], reporter: Reporter) -> int: ...Core checker functionality providing detailed AST analysis, scope management, binding tracking, and extensible analysis capabilities for advanced use cases.
class Checker:
def __init__(
self,
tree: ast.AST,
filename: str = ...,
builtins: Iterable[str] | None = ...,
withDoctest: bool = ...,
file_tokens: tuple[Any, ...] = ...,
) -> None: ...
def report(self, messageClass: Callable[_P, Message], *args: _P.args, **kwargs: _P.kwargs) -> None: ...Comprehensive message classes for different types of analysis issues including import problems, undefined names, syntax errors, and format string validation errors.
class Message:
def __init__(self, filename, loc: ast.AST) -> None: ...
class UnusedImport(Message): ...
class UndefinedName(Message): ...
class ImportStarUsed(Message): ...Configurable reporting system for displaying analysis results to different output streams with support for custom error handling and formatting.
class Reporter:
def __init__(self, warningStream, errorStream) -> None: ...
def flake(self, message) -> None: ...
def syntaxError(self, filename, msg, lineno, offset, text) -> None: ...from collections.abc import Iterable, Iterator, Sequence, Callable
from re import Pattern
from typing import Any, ClassVar, TypeVar, overload
from typing_extensions import Literal, ParamSpec, TypeAlias
import ast
# Version information
__version__: str
# Type variables
_AnyFunction: TypeAlias = Callable[..., Any]
_F = TypeVar("_F", bound=_AnyFunction)
_P = ParamSpec("_P")
_T = TypeVar("_T")
# Format string types
_FormatType: TypeAlias = tuple[str | None, str | None, str | None, str | None, str]
_PercentFormat: TypeAlias = tuple[str, _FormatType | None]
# Omission type for AST traversal
_OmitType: TypeAlias = str | tuple[str, ...] | None