or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

ast-checker.mdcode-analysis.mderror-messages.mdindex.mdreport-generation.md
tile.json

tessl/pypi-types--pyflakes

Type stubs for pyflakes, a Python source code analysis tool designed to detect errors in Python files

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
pypipkg:pypi/types-pyflakes@2.5.x

To install, run

npx @tessl/cli install tessl/pypi-types--pyflakes@2.5.0

index.mddocs/

Types-PyFlakes

Type 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.

Package Information

  • Package Name: types-pyflakes
  • Language: Python
  • Installation: pip install types-pyflakes
  • Provides Type Stubs For: pyflakes

Core Imports

import 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, checkRecursive

For custom analysis:

from pyflakes.checker import Checker
from pyflakes.reporter import Reporter

Basic Usage

from 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)

Architecture

Pyflakes operates through a multi-stage analysis pipeline:

  • API Layer (pyflakes.api): High-level functions for checking code strings, files, and directories
  • Checker (pyflakes.checker): Core AST analysis engine with sophisticated scope and binding management
  • Messages (pyflakes.messages): Comprehensive error and warning message classes for different issue types
  • Reporter (pyflakes.reporter): Configurable output system for displaying analysis results

The 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.

Capabilities

Code Analysis API

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: ...

Code Analysis API

AST Checker and Analysis Engine

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: ...

AST Checker

Error Messages and Warnings

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): ...

Error Messages

Report Generation

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: ...

Report Generation

Types

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