CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-types--pyflakes

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

Overview
Eval results
Files

error-messages.mddocs/

Error Messages and Warnings

Comprehensive message classes representing different types of analysis issues that pyflakes can detect. Each message class corresponds to a specific type of problem in Python code, from unused imports to syntax errors.

Capabilities

Base Message Class

Foundation class for all pyflakes messages, providing common attributes and initialization.

class Message:
    """
    Base class for all pyflakes messages.
    
    Attributes:
    - message: ClassVar[str], message template string
    - message_args: tuple[Any, ...], arguments for message formatting
    - filename: Any, source file where issue occurs
    - lineno: int, line number of issue
    - col: int, column number of issue
    """
    
    def __init__(self, filename, loc: ast.AST) -> None:
        """
        Initialize message with location information.
        
        Parameters:
        - filename: source file path
        - loc: AST node where issue occurs
        """

Import-Related Messages

Messages for issues with import statements, including unused imports, import conflicts, and star import problems.

class UnusedImport(Message):
    """
    Unused import warning.
    
    Attributes:
    - message_args: tuple[Any], imported name
    """
    def __init__(self, filename, loc: ast.AST, name) -> None: ...

class RedefinedWhileUnused(Message):
    """
    Name redefined while original binding unused.
    
    Attributes:
    - message_args: tuple[Any, int], name and original line number
    """
    def __init__(self, filename, loc: ast.AST, name, orig_loc: ast.AST) -> None: ...

class ImportShadowedByLoopVar(Message):
    """
    Import shadowed by loop variable.
    
    Attributes:
    - message_args: tuple[Any, int], name and original line number
    """
    def __init__(self, filename, loc: ast.AST, name, orig_loc: ast.AST) -> None: ...

class ImportStarNotPermitted(Message):
    """
    Star import not permitted in this context.
    
    Attributes:
    - message_args: Any, module name
    """
    def __init__(self, filename, loc, modname) -> None: ...

class ImportStarUsed(Message):
    """
    Star import used (informational).
    
    Attributes:
    - message_args: tuple[Any], module name
    """
    def __init__(self, filename, loc: ast.AST, modname) -> None: ...

class ImportStarUsage(Message):
    """
    Name may be undefined due to star import.
    
    Attributes:
    - message_args: tuple[Any, Any], name and from_list
    """
    def __init__(self, filename, loc: ast.AST, name, from_list) -> None: ...

Name Resolution Messages

Messages for undefined names, local variable issues, and export problems.

class UndefinedName(Message):
    """
    Undefined name error.
    
    Attributes:
    - message_args: tuple[Any], undefined name
    """
    def __init__(self, filename, loc: ast.AST, name) -> None: ...

class UndefinedExport(Message):
    """
    Name in __all__ is not defined.
    
    Attributes:
    - message_args: tuple[Any], exported name
    """
    def __init__(self, filename, loc: ast.AST, name) -> None: ...

class UndefinedLocal(Message):
    """
    Local variable referenced before assignment.
    
    Attributes:
    - default: ClassVar[str], default message
    - builtin: ClassVar[str], builtin override message
    - message_args: tuple[Any, int], name and original line number
    """
    def __init__(self, filename, loc: ast.AST, name, orig_loc: ast.AST) -> None: ...

class UnusedVariable(Message):
    """
    Local variable assigned but never used.
    
    Attributes:
    - message_args: tuple[Any], variable names
    """
    def __init__(self, filename, loc: ast.AST, names) -> None: ...

Function and Argument Messages

Messages for function definition and argument-related issues.

class DuplicateArgument(Message):
    """
    Duplicate argument name in function definition.
    
    Attributes:
    - message_args: tuple[Any], argument name
    """
    def __init__(self, filename, loc: ast.AST, name) -> None: ...

Dictionary and Data Structure Messages

Messages for issues with dictionary literals and data structures.

class MultiValueRepeatedKeyLiteral(Message):
    """
    Dictionary has repeated key (literal).
    
    Attributes:
    - message_args: tuple[Any], repeated key
    """
    def __init__(self, filename, loc: ast.AST, key) -> None: ...

class MultiValueRepeatedKeyVariable(Message):
    """
    Dictionary has repeated key (variable).
    
    Attributes:
    - message_args: tuple[Any], repeated key variable
    """
    def __init__(self, filename, loc: ast.AST, key) -> None: ...

Future Import Messages

Messages for future import issues and timing problems.

class LateFutureImport(Message):
    """
    __future__ import after other statements.
    
    Attributes:
    - message_args: tuple[()], empty tuple
    """
    def __init__(self, filename, loc: ast.AST) -> None: ...

class FutureFeatureNotDefined(Message):
    """
    __future__ feature name not recognized.
    
    Attributes:
    - message_args: tuple[Any], feature name
    """
    def __init__(self, filename, loc: ast.AST, name) -> None: ...

Control Flow Messages

Messages for control flow statement issues and syntax problems.

# Simple message classes (no additional parameters)
class ReturnOutsideFunction(Message):
    """'return' outside function."""

class YieldOutsideFunction(Message):
    """'yield' outside function."""

class ContinueOutsideLoop(Message):
    """'continue' not properly in loop."""

class BreakOutsideLoop(Message):
    """'break' outside loop."""

class ContinueInFinally(Message):
    """'continue' not supported inside 'finally' clause."""

class DefaultExceptNotLast(Message):
    """Default 'except:' must be last."""

class TwoStarredExpressions(Message):
    """Two starred expressions in assignment."""

class TooManyExpressionsInStarredAssignment(Message):
    """Too many expressions on left side of starred assignment."""

Code Quality Messages

Messages for code quality issues and potential problems.

class IfTuple(Message):
    """Use of tuple in if condition (likely missing comma)."""

class AssertTuple(Message):
    """Use of tuple in assert (likely missing comma)."""

class RaiseNotImplemented(Message):
    """Use 'raise NotImplementedError' instead of 'raise NotImplemented'."""

class InvalidPrintSyntax(Message):
    """Invalid print statement syntax (Python 3 style needed)."""

class IsLiteral(Message):
    """Use of 'is' with literal (should use '==')."""

class FStringMissingPlaceholders(Message):
    """f-string is missing placeholders."""

Annotation Messages

Messages for type annotation syntax and parsing errors.

class ForwardAnnotationSyntaxError(Message):
    """
    Syntax error in forward annotation.
    
    Attributes:
    - message_args: tuple[Any], annotation text
    """
    def __init__(self, filename, loc: ast.AST, annotation) -> None: ...

class CommentAnnotationSyntaxError(Message):
    """
    Syntax error in type comment annotation.
    
    Attributes:
    - message_args: tuple[Any], annotation text
    """
    def __init__(self, filename, loc: ast.AST, annotation) -> None: ...

Doctest Messages

Messages for doctest-related issues.

class DoctestSyntaxError(Message):
    """
    Syntax error in doctest block.
    
    Attributes:
    - message_args: tuple[()], empty tuple
    """
    def __init__(self, filename, loc: ast.AST, position: tuple[int, int] | None = ...) -> None: ...

String Format Messages

Messages for string formatting validation, including both .format() and % formatting styles.

.format() Style Messages

class StringDotFormatExtraPositionalArguments(Message):
    """
    Too many positional arguments for str.format().
    
    Attributes:
    - message_args: tuple[Any], extra positions
    """
    def __init__(self, filename, loc: ast.AST, extra_positions) -> None: ...

class StringDotFormatExtraNamedArguments(Message):
    """
    Unused named arguments in str.format().
    
    Attributes:
    - message_args: tuple[Any], extra keywords
    """
    def __init__(self, filename, loc: ast.AST, extra_keywords) -> None: ...

class StringDotFormatMissingArgument(Message):
    """
    Missing arguments for str.format().
    
    Attributes:
    - message_args: tuple[Any], missing arguments
    """
    def __init__(self, filename, loc: ast.AST, missing_arguments) -> None: ...

class StringDotFormatMixingAutomatic(Message):
    """Mixing automatic and manual field numbering in str.format()."""

class StringDotFormatInvalidFormat(Message):
    """
    Invalid format specification in str.format().
    
    Attributes:
    - message_args: tuple[Any], error description
    """
    def __init__(self, filename, loc: ast.AST, error) -> None: ...

Percent Formatting Messages

class PercentFormatInvalidFormat(Message):
    """
    Invalid percent format specification.
    
    Attributes:
    - message_args: tuple[Any], error description
    """
    def __init__(self, filename, loc: ast.AST, error) -> None: ...

class PercentFormatMixedPositionalAndNamed(Message):
    """Cannot mix positional and named arguments in percent formatting."""

class PercentFormatUnsupportedFormatCharacter(Message):
    """
    Unsupported format character in percent formatting.
    
    Attributes:
    - message_args: tuple[Any], format character
    """
    def __init__(self, filename, loc: ast.AST, c) -> None: ...

class PercentFormatPositionalCountMismatch(Message):
    """
    Wrong number of arguments for percent formatting.
    
    Attributes:
    - message_args: tuple[int, int], expected and provided counts
    """
    def __init__(self, filename, loc: ast.AST, n_placeholders: int, n_substitutions: int) -> None: ...

class PercentFormatExtraNamedArguments(Message):
    """
    Unused named arguments in percent formatting.
    
    Attributes:
    - message_args: tuple[Any], extra keywords
    """
    def __init__(self, filename, loc: ast.AST, extra_keywords) -> None: ...

class PercentFormatMissingArgument(Message):
    """
    Missing arguments for percent formatting.
    
    Attributes:
    - message_args: tuple[Any], missing arguments
    """
    def __init__(self, filename, loc: ast.AST, missing_arguments) -> None: ...

class PercentFormatExpectedMapping(Message):
    """Percent formatting expected mapping object."""

class PercentFormatExpectedSequence(Message):
    """Percent formatting expected sequence object."""

class PercentFormatStarRequiresSequence(Message):
    """Percent formatting * requires sequence."""

Usage Example:

from pyflakes.checker import Checker
from pyflakes.messages import UnusedImport, UndefinedName
import ast

# Check if specific message types are present
code = """
import os  # This will be unused
print(undefined_variable)  # This will be undefined
"""

tree = ast.parse(code)
checker = Checker(tree, "example.py")

for message in checker.messages:
    if isinstance(message, UnusedImport):
        print(f"Unused import: {message.message_args[0]}")
    elif isinstance(message, UndefinedName):
        print(f"Undefined name: {message.message_args[0]}")

Install with Tessl CLI

npx tessl i tessl/pypi-types--pyflakes

docs

ast-checker.md

code-analysis.md

error-messages.md

index.md

report-generation.md

tile.json