sdkagent

flake8 API reference

166 public APIs from flake8 (pycqa/flake8) — 36 classes, 31 functions, 99 methods. Signatures extracted by static analysis of the actual source.

Repository: pycqa/flake8

KindCount
Classes36
Functions31
Methods99

API list

classexample-plugin.src.flake8_example_plugin.off_by_default.ExampleTwo
Second Example Plugin.
methodexample-plugin.src.flake8_example_plugin.off_by_default.ExampleTwo.run()
Do nothing.
classexample-plugin.src.flake8_example_plugin.on_by_default.ExampleOne
First Example Plugin.
methodexample-plugin.src.flake8_example_plugin.on_by_default.ExampleOne.run()
Do nothing.
classsrc.flake8.api.legacy.Report
Public facing object that mimic's Flake8 2.0's API.
methodsrc.flake8.api.legacy.Report.get_statistics(violation:str) -> list[str]
Get the list of occurrences of a violation.
methodsrc.flake8.api.legacy.Report.total_errors() -> int
Return the total number of errors.
classsrc.flake8.api.legacy.StyleGuide
Public facing object that mimic's Flake8 2.0's StyleGuide.
methodsrc.flake8.api.legacy.StyleGuide.check_files(paths:list[str] | None=None) -> Report
Run collected checks on the files provided.
methodsrc.flake8.api.legacy.StyleGuide.excluded(filename:str, parent:str | None=None) -> bool
Determine if a file is excluded.
methodsrc.flake8.api.legacy.StyleGuide.init_report(reporter:type[formatter.BaseFormatter] | None=None) -> None
Set up a formatter for this run of Flake8.
methodsrc.flake8.api.legacy.StyleGuide.input_file(filename:str, lines:Any | None=None, expected:Any | None=None, line_offset:Any | None=0) -> Report
Run collected checks on a single file.
methodsrc.flake8.api.legacy.StyleGuide.options() -> argparse.Namespace
Return application's options.
methodsrc.flake8.api.legacy.StyleGuide.paths() -> list[str]
Return the extra arguments passed as paths.
funcsrc.flake8.api.legacy.get_style_guide(**kwargs:Any) -> StyleGuide
Provision a StyleGuide for use.
classsrc.flake8.checker.FileChecker
Manage running checks for a file and aggregate the results.
methodsrc.flake8.checker.FileChecker.handle_newline(token_type:int) -> None
Handle the logic when encountering a newline token.
methodsrc.flake8.checker.FileChecker.process_tokens() -> None
Process tokens and trigger checks.
methodsrc.flake8.checker.FileChecker.report(error_code:str | None, line_number:int, column:int, text:str) -> str
Report an error by storing it in the results list.
methodsrc.flake8.checker.FileChecker.run_ast_checks() -> None
Run all checks expecting an abstract syntax tree.
methodsrc.flake8.checker.FileChecker.run_check(plugin:LoadedPlugin, **arguments:Any) -> Any
Run the check in a single plugin.
methodsrc.flake8.checker.FileChecker.run_checks() -> tuple[str, Results, dict[str, int]]
Run checks against the file.
methodsrc.flake8.checker.FileChecker.run_logical_checks() -> None
Run all checks expecting a logical line.
methodsrc.flake8.checker.FileChecker.run_physical_checks(physical_line:str) -> None
Run all checks for a given physical line.
classsrc.flake8.checker.Manager
Manage the parallelism and checker instances for each plugin and file.
methodsrc.flake8.checker.Manager.report() -> tuple[int, int]
Report all of the errors found in the managed file checkers.
methodsrc.flake8.checker.Manager.run() -> None
Run all the checkers.
methodsrc.flake8.checker.Manager.run_parallel() -> None
Run the checkers in parallel.
methodsrc.flake8.checker.Manager.run_serial() -> None
Run the checkers in serial.
methodsrc.flake8.checker.Manager.start() -> None
Start checking files.
methodsrc.flake8.checker.Manager.stop() -> None
Stop checking files.
funcsrc.flake8.checker.find_offset(offset:int, mapping:processor._LogicalMapping) -> tuple[int, int]
Find the offset tuple for a single offset.
funcsrc.flake8.configure_logging(verbosity:int, filename:str | None=None, logformat:str=LOG_FORMAT) -> None
Configure logging for flake8.
classsrc.flake8.exceptions.EarlyQuit
Except raised when encountering a KeyboardInterrupt.
classsrc.flake8.exceptions.ExecutionError
Exception raised during execution of Flake8.
classsrc.flake8.exceptions.FailedToLoadPlugin
Exception raised when a plugin fails to load.
classsrc.flake8.exceptions.Flake8Exception
Plain Flake8 exception.
classsrc.flake8.exceptions.PluginExecutionFailed
The plugin failed during execution.
classsrc.flake8.exceptions.PluginRequestedUnknownParameters
The plugin requested unknown parameters.
classsrc.flake8.formatting.base.BaseFormatter
Class defining the formatter interface.
methodsrc.flake8.formatting.base.BaseFormatter.after_init() -> None
Initialize the formatter further.
methodsrc.flake8.formatting.base.BaseFormatter.beginning(filename:str) -> None
Notify the formatter that we're starting to process a file.
methodsrc.flake8.formatting.base.BaseFormatter.finished(filename:str) -> None
Notify the formatter that we've finished processing a file.
methodsrc.flake8.formatting.base.BaseFormatter.format(error:Violation) -> str | None
Format an error reported by Flake8.
methodsrc.flake8.formatting.base.BaseFormatter.handle(error:Violation) -> None
Handle an error reported by Flake8.
methodsrc.flake8.formatting.base.BaseFormatter.show_benchmarks(benchmarks:list[tuple[str, float]]) -> None
Format and print the benchmarks.
methodsrc.flake8.formatting.base.BaseFormatter.show_source(error:Violation) -> str | None
Show the physical line generating the error.
methodsrc.flake8.formatting.base.BaseFormatter.show_statistics(statistics:Statistics) -> None
Format and print the statistics.
methodsrc.flake8.formatting.base.BaseFormatter.start() -> None
Prepare the formatter to receive input.
methodsrc.flake8.formatting.base.BaseFormatter.stop() -> None
Clean up after reporting is finished.
methodsrc.flake8.formatting.base.BaseFormatter.write(line:str | None, source:str | None) -> None
Write the line either to the output file or stdout.
classsrc.flake8.formatting.default.Default
Default formatter for Flake8.
methodsrc.flake8.formatting.default.Default.after_init() -> None
Check for a custom format string.
classsrc.flake8.formatting.default.FilenameOnly
Only print filenames, e.g., flake8 -q.
methodsrc.flake8.formatting.default.FilenameOnly.after_init() -> None
Initialize our set of filenames.
methodsrc.flake8.formatting.default.FilenameOnly.format(error:Violation) -> str | None
Ensure we only print each error once.
methodsrc.flake8.formatting.default.FilenameOnly.show_source(error:Violation) -> str | None
Do not include the source code.
classsrc.flake8.formatting.default.Nothing
Print absolutely nothing.
methodsrc.flake8.formatting.default.Nothing.format(error:Violation) -> str | None
Do nothing.
methodsrc.flake8.formatting.default.Nothing.show_source(error:Violation) -> str | None
Do not print the source.
classsrc.flake8.formatting.default.Pylint
Pylint formatter for Flake8.
methodsrc.flake8.formatting.default.SimpleFormatter.format(error:Violation) -> str | None
Format and write error out.
classsrc.flake8.main.application.Application
Abstract our application into a class.
methodsrc.flake8.main.application.Application.exit_code() -> int
Return the program exit code.
methodsrc.flake8.main.application.Application.initialize(argv:Sequence[str]) -> None
Initialize the application to be run.
methodsrc.flake8.main.application.Application.make_file_checker_manager(argv:Sequence[str]) -> None
Initialize our FileChecker Manager.
methodsrc.flake8.main.application.Application.make_formatter() -> None
Initialize a formatter based on the parsed options.
methodsrc.flake8.main.application.Application.make_guide() -> None
Initialize our StyleGuide.
methodsrc.flake8.main.application.Application.report() -> None
Report errors, statistics, and benchmarks.
methodsrc.flake8.main.application.Application.report_errors() -> None
Report all the errors found by flake8 3.0.
methodsrc.flake8.main.application.Application.report_statistics() -> None
Aggregate and report statistics from this run.
methodsrc.flake8.main.application.Application.run(argv:Sequence[str]) -> None
Run our application.
methodsrc.flake8.main.application.Application.run_checks() -> None
Run the actual checks with the FileChecker Manager.
funcsrc.flake8.main.cli.main(argv:Sequence[str] | None=None) -> int
Execute the main bit of the application.
funcsrc.flake8.main.debug.information(version:str, plugins:Plugins) -> dict[str, Any]
Generate the information to be printed for the bug report.
classsrc.flake8.main.options.JobsArgument
Type callback for the --jobs argument.
funcsrc.flake8.main.options.register_default_options(option_manager:OptionManager) -> None
Register the default options on our OptionManager.
funcsrc.flake8.options.config.load_config(config:str | None, extra:list[str], *isolated:bool=False) -> tuple[configparser.RawConfigParser, str]
Load the configuration given the user options.
funcsrc.flake8.options.config.parse_config(option_manager:OptionManager, cfg:configparser.RawConfigParser, cfg_dir:str) -> dict[str, Any]
Parse and normalize the typed configuration options.
classsrc.flake8.options.manager.Option
Our wrapper around an argparse argument parsers to add features.
methodsrc.flake8.options.manager.Option.filtered_option_kwargs() -> dict[str, Any]
Return any actually-specified arguments.
methodsrc.flake8.options.manager.Option.normalize(value:Any, *normalize_args:str) -> Any
Normalize the value based on the option configuration.
methodsrc.flake8.options.manager.OptionManager.add_option(*args:Any, **kwargs:Any) -> None
Create and register a new option.
methodsrc.flake8.options.manager.OptionManager.register_plugins(plugins:Plugins) -> None
Register the plugin options (if needed).
funcsrc.flake8.options.parse_args.parse_args(argv:Sequence[str]) -> tuple[finder.Plugins, argparse.Namespace]
Procedure for parsing args, config, loading plugins.
classsrc.flake8.plugins.finder.Checkers
Classified plugins needed for checking.
classsrc.flake8.plugins.finder.LoadedPlugin
Represents a plugin after being imported.
methodsrc.flake8.plugins.finder.LoadedPlugin.entry_name() -> str
Return the name given in the packaging metadata.
classsrc.flake8.plugins.finder.Plugin
A plugin before loading.
classsrc.flake8.plugins.finder.PluginOptions
Options related to plugin loading.
methodsrc.flake8.plugins.finder.PluginOptions.blank() -> PluginOptions
Make a blank PluginOptions, mostly used for tests.
classsrc.flake8.plugins.finder.Plugins
Classified plugins.
methodsrc.flake8.plugins.finder.Plugins.all_plugins() -> Generator[LoadedPlugin]
Return an iterator over all :class:`LoadedPlugin`s.
methodsrc.flake8.plugins.finder.Plugins.versions_str() -> str
Return a user-displayed list of plugin versions.
funcsrc.flake8.plugins.finder.find_plugins(cfg:configparser.RawConfigParser, opts:PluginOptions) -> list[Plugin]
Discovers all plugins (but does not load them).
funcsrc.flake8.plugins.finder.load_plugins(plugins:list[Plugin], opts:PluginOptions) -> Plugins
Load and classify all flake8 plugins.
funcsrc.flake8.plugins.finder.parse_plugin_options(cfg:configparser.RawConfigParser, cfg_dir:str, *enable_extensions:str | None, *require_plugins:str | None) -> PluginOptions
Parse plugin loading related options.
funcsrc.flake8.plugins.pycodestyle.pycodestyle_physical(indent_char:Any, line_number:Any, lines:Any, max_line_length:Any, multiline:Any, noqa:Any, physical_line:Any, total_lines:Any) -> Generator[tuple[int, str]]
Run pycodestyle physical checks.
methodsrc.flake8.plugins.pyflakes.FlakesChecker.add_options(parser:OptionManager) -> None
Register options for PyFlakes on the Flake8 OptionManager.
methodsrc.flake8.plugins.pyflakes.FlakesChecker.parse_options(options:argparse.Namespace) -> None
Parse option values from Flake8's OptionManager.
methodsrc.flake8.plugins.pyflakes.FlakesChecker.run() -> Generator[tuple[int, int, str, type[Any]]]
Run the plugin.
funcsrc.flake8.plugins.reporter.make(reporters:dict[str, LoadedPlugin], options:argparse.Namespace) -> BaseFormatter
Make the formatter from the requested user options.
classsrc.flake8.processor.FileProcessor
Processes a file and holds state.
methodsrc.flake8.processor.FileProcessor.build_ast() -> ast.AST
Build an abstract syntax tree from the list of lines.
methodsrc.flake8.processor.FileProcessor.delete_first_token() -> None
Delete the first token in the list of tokens.
methodsrc.flake8.processor.FileProcessor.file_tokens() -> list[tokenize.TokenInfo]
Return the complete set of tokens for a file.
methodsrc.flake8.processor.FileProcessor.fstring_start(lineno:int) -> None
Signal the beginning of an fstring.
methodsrc.flake8.processor.FileProcessor.generate_tokens() -> Generator[tokenize.TokenInfo]
Tokenize the file and yield the tokens.
methodsrc.flake8.processor.FileProcessor.multiline_string(token:tokenize.TokenInfo) -> Generator[str]
Iterate through the lines of a multiline string.
methodsrc.flake8.processor.FileProcessor.next_line() -> str
Get the next line from the list.
methodsrc.flake8.processor.FileProcessor.next_logical_line() -> None
Record the previous logical line.
methodsrc.flake8.processor.FileProcessor.noqa_line_for(line_number:int) -> str | None
Retrieve the line which will be used to determine noqa.
methodsrc.flake8.processor.FileProcessor.read_lines() -> list[str]
Read the lines for this file checker.
methodsrc.flake8.processor.FileProcessor.read_lines_from_filename() -> list[str]
Read the lines for a file.
methodsrc.flake8.processor.FileProcessor.read_lines_from_stdin() -> list[str]
Read the lines from standard in.
methodsrc.flake8.processor.FileProcessor.reset_blank_before() -> None
Reset the blank_before attribute to zero.
methodsrc.flake8.processor.FileProcessor.strip_utf_bom() -> None
Strip the UTF bom from the lines of the file.
methodsrc.flake8.processor.FileProcessor.tstring_start(lineno:int) -> None
Signal the beginning of an tstring.
methodsrc.flake8.processor.FileProcessor.update_checker_state_for(plugin:LoadedPlugin) -> None
Update the checker_state attribute for the plugin.
methodsrc.flake8.processor.FileProcessor.update_state(mapping:_LogicalMapping) -> None
Update the indent level based on the logical line mapping.
methodsrc.flake8.processor.FileProcessor.visited_new_blank_line() -> None
Note that we visited a new blank line.
funcsrc.flake8.processor.count_parentheses(current_parentheses_count:int, token_text:str) -> int
Count the number of parentheses.
funcsrc.flake8.processor.expand_indent(line:str) -> int
Return the amount of indentation.
funcsrc.flake8.processor.is_eol_token(token:tokenize.TokenInfo) -> bool
Check if the token is an end-of-line token.
funcsrc.flake8.processor.is_multiline_string(token:tokenize.TokenInfo) -> bool
Check if this is a multiline string.
funcsrc.flake8.processor.mutate_string(text:str) -> str
Replace contents with 'xxx' to prevent syntax matching.
funcsrc.flake8.processor.token_is_newline(token:tokenize.TokenInfo) -> bool
Check if the token type is a newline token type.
classsrc.flake8.statistics.Key
Simple key structure for the Statistics dictionary.
methodsrc.flake8.statistics.Key.create_from(error:Violation) -> Key
Create a Key from :class:`flake8.violation.Violation`.
methodsrc.flake8.statistics.Key.matches(prefix:str, filename:str | None) -> bool
Determine if this key matches some constraints.
classsrc.flake8.statistics.Statistic
Simple wrapper around the logic of each statistic.
methodsrc.flake8.statistics.Statistic.create_from(error:Violation) -> Statistic
Create a Statistic from a :class:`flake8.violation.Violation`.
classsrc.flake8.statistics.Statistics
Manager of aggregated statistics for a run of Flake8.
methodsrc.flake8.statistics.Statistics.error_codes() -> list[str]
Return all unique error codes stored.
methodsrc.flake8.statistics.Statistics.record(error:Violation) -> None
Add the fact that the error was seen in the file.
methodsrc.flake8.statistics.Statistics.statistics_for(prefix:str, filename:str | None=None) -> Generator[Statistic]
Generate statistics for the prefix and filename.
classsrc.flake8.style_guide.Decision
Enum representing whether a code should be ignored or selected.
classsrc.flake8.style_guide.DecisionEngine
A class for managing the decision process around violations.
methodsrc.flake8.style_guide.DecisionEngine.decision_for(code:str) -> Decision
Return the decision for a specific code.
methodsrc.flake8.style_guide.DecisionEngine.make_decision(code:str) -> Decision
Decide if code should be ignored or selected.
methodsrc.flake8.style_guide.DecisionEngine.was_ignored(code:str) -> Selected | Ignored
Determine if the code has been ignored by the user.
methodsrc.flake8.style_guide.DecisionEngine.was_selected(code:str) -> Selected | Ignored
Determine if the code has been selected by the user.
classsrc.flake8.style_guide.Ignored
Enum representing an explicitly or implicitly ignored code.
classsrc.flake8.style_guide.Selected
Enum representing an explicitly or implicitly selected code.
classsrc.flake8.style_guide.StyleGuide
Manage a Flake8 user's style guide.
methodsrc.flake8.style_guide.StyleGuide.applies_to(filename:str) -> bool
Check if this StyleGuide applies to the file.
methodsrc.flake8.style_guide.StyleGuide.copy(filename:str | None=None, extend_ignore_with:Sequence[str] | None=None) -> StyleGuide
Create a copy of this style guide with different values.
methodsrc.flake8.style_guide.StyleGuide.handle_error(code:str, filename:str, line_number:int, column_number:int, text:str, physical_line:str | None=None) -> int
Handle an error reported by a check.
methodsrc.flake8.style_guide.StyleGuide.processing_file(filename:str) -> Generator[StyleGuide]
Record the fact that we're processing the file's results.
methodsrc.flake8.style_guide.StyleGuide.should_report_error(code:str) -> Decision
Determine if the error code should be reported or ignored.
classsrc.flake8.style_guide.StyleGuideManager
Manage multiple style guides for a single run.
methodsrc.flake8.style_guide.StyleGuideManager.handle_error(code:str, filename:str, line_number:int, column_number:int, text:str, physical_line:str | None=None) -> int
Handle an error reported by a check.
methodsrc.flake8.style_guide.StyleGuideManager.processing_file(filename:str) -> Generator[StyleGuide]
Record the fact that we're processing the file's results.
funcsrc.flake8.utils.fnmatch(filename:str, patterns:Sequence[str]) -> bool
Wrap :func:`fnmatch.fnmatch` to add some functionality.
funcsrc.flake8.utils.get_python_version() -> str
Find and format the python implementation and version.
funcsrc.flake8.utils.is_using_stdin(paths:list[str]) -> bool
Determine if we're going to read from stdin.
funcsrc.flake8.utils.matches_filename(path:str, patterns:Sequence[str], log_message:str, logger:logging.Logger) -> bool
Use fnmatch to discern if a path exists in patterns.
funcsrc.flake8.utils.normalize_path(path:str, parent:str=os.curdir) -> str
Normalize a single-path.
funcsrc.flake8.utils.normalize_paths(paths:Sequence[str], parent:str=os.curdir) -> list[str]
Normalize a list of paths relative to a parent directory.
funcsrc.flake8.utils.normalize_pypi_name(s:str) -> str
Normalize a distribution name according to PEP 503.
funcsrc.flake8.utils.parse_comma_separated_list(value:str, regexp:Pattern[str]=COMMA_SEPARATED_LIST_RE) -> list[str]
Parse a comma-separated list.
funcsrc.flake8.utils.parse_files_to_codes_mapping(value_:Sequence[str] | str) -> list[tuple[str, list[str]]]
Parse a files-to-codes mapping.
funcsrc.flake8.utils.stdin_get_lines() -> list[str]
Return lines of stdin split according to file splitting.
funcsrc.flake8.utils.stdin_get_value() -> str
Get and cache it so plugins can use it.
classsrc.flake8.violation.Violation
Class representing a violation reported by Flake8.
methodsrc.flake8.violation.Violation.is_inline_ignored(disable_noqa:bool) -> bool
Determine if a comment has been added to ignore this line.

About this data

These signatures were extracted from the public source of pycqa/flake8 using Python's ast module. Argument names, default values, type annotations and return types are taken verbatim from the code. Implementation bodies are never stored. See how it works for details.

Back to all 805 libraries