flakeheaven._patched._app

class flakeheaven._patched._app.FlakeHeavenApplication(program='flake8', version='4.0.1')[source]

Bases: flake8.main.application.Application

Reloaded flake8 original entrypoint to provide support for some features: + pyproject.toml support + replace CheckersManager to support for plugins option + register custom formatters

Initialize our application.

Parameters
  • program (str) – The name of the program/application that we’re executing.

  • version (str) – The version of the program/application we’re executing.

args: Optional[List[str]]

The left over arguments that were not parsed by option_manager

check_plugins: Optional[plugin_manager.Checkers]

The instance of flake8.plugins.manager.Checkers

end_time: Optional[float]

The timestamp when the Application finished reported errors.

static extract_toml_config_path(argv: List[str]) Tuple[Optional[pathlib.Path], List[str]][source]
file_checker_manager: Optional[checker.Manager]

The flake8.checker.Manager that will handle running all of the checks selected by the user.

find_plugins(config_finder) None[source]

Find and load the plugins for this application.

Set the check_plugins and formatting_plugins attributes based on the discovered plugins found.

Parameters

config_finder (config.ConfigFileFinder) – The finder for finding and reading configuration files.

formatter: Optional[BaseFormatter]

The user-selected formatter from formatting_plugins

formatting_plugins: Optional[plugin_manager.ReportFormatters]

The instance of flake8.plugins.manager.ReportFormatters

get_toml_config(path: Optional[pathlib.Path] = None, *, enforce_keys_from: Dict[str, flake8.options.manager.Option]) Dict[str, Any][source]

Extract config from TOML.

Parameters
  • path – toml filepath. If not set, searches in cwd parents.

  • enforce_keys_from – Mapping of configuration option names to Option instances. It is used to convert dashed-names in toml to ConfigParser namespace so it can be updated via its __dict__. Typically, it comes from either config_options, or directly from config_options_dict.

guide: flakeheaven._patched._style_guide.FlakeHeavenStyleGuideManager

The flake8.style_guide.StyleGuideManager built from the user’s options

make_file_checker_manager() None[source]

Initialize our FileChecker Manager.

make_formatter(*args, **kwargs) None[source]

Initialize a formatter based on the parsed options.

make_guide() None[source]

Patched StyleGuide creation just to use FlakeHeavenStyleGuideManager instead of original one.

property option_manager

We overload this property only to specify setter.

options: Optional[argparse.Namespace]

The user-supplied options parsed into an instance of argparse.Namespace

parse_configuration_and_cli(config_finder, argv: List[str]) None[source]

Parse configuration files and the CLI options.

Parameters
  • config_finder (config.ConfigFileFinder) – The finder for finding and reading configuration files.

  • argv (list) – Command-line arguments passed in directly.

parse_preliminary_options(argv: List[str]) Tuple[argparse.Namespace, List[str]][source]

Get preliminary options from the CLI, pre-plugin-loading.

We need to know the values of a few standard options so that we can locate configuration files and configure logging.

Since plugins aren’t loaded yet, there may be some as-yet-unknown options; we ignore those for now, they’ll be parsed later when we do real option parsing.

Parameters

argv (list) – Command-line arguments passed in directly.

Returns

Populated namespace and list of remaining argument strings.

Return type

(argparse.Namespace, list)

parsed_diff: Dict[str, Set[int]]

The parsed diff information

run_checks()[source]

Run the actual checks with the FileChecker Manager.

This method encapsulates the logic to make a Manger instance run the checks it is managing.

Parameters

files (list) – List of filenames to process