flakeheaven._logic package

class flakeheaven._logic.Snapshot(*, cache_path: pathlib.Path, file_path: pathlib.Path)[source]

Bases: object

_digest: Optional[str] = None
_exists: Optional[bool] = None
_results = None
classmethod create(checker: flake8.checker.FileChecker, options: flake8.options.manager.OptionManager) flakeheaven._logic._snapshot.Snapshot[source]
property digest: Optional[str]

Get hex digest for the current content of the file

dump(results) None[source]
dumps(results) str[source]
exists() bool[source]

Returns True if cache file exists and is actual.

property results

returns cached checks results for the given file

flakeheaven._logic.check_include(code: str, rules: List[str]) bool[source]
  1. Validate rules

  2. Return True if rule explicitly included

  3. Return False if rule explicitly excluded

  4. Return True if the latest glob-matching rule is include

  5. Return False if the latest glob-matching rule is exclude

flakeheaven._logic.color_code(code: str) str[source]
flakeheaven._logic.color_description(text: str) str[source]
flakeheaven._logic.colored(text: object, color: str, attrs: Optional[List[str]] = None) str[source]

termcolor.colored implementation on top of colorama

flakeheaven._logic.extract(name) Dict[str, str][source]
flakeheaven._logic.get_exceptions(path: Union[str, pathlib.Path], exceptions: Dict[str, Dict[str, List[str]]], root: Optional[pathlib.Path] = None) Dict[str, List[str]][source]

Just like in get_plugin_rules. The algorithm:

  1. Try to find exact match (normalizing as all packages names normalized)

  2. Try to find globs that match and select the longest one (nginx-style)

flakeheaven._logic.get_installed(app, *, initialize: bool = True, initialize_args: Optional[List[str]] = None) Iterator[Dict[str, Any]][source]
flakeheaven._logic.get_plugin_name(plugin: Dict[str, Any]) str[source]

Get plugin name from plugin info

Users expect the same plugin name as the name of the package that provides plugin. However, that’s not true for some plugins. Also, some plugins has different module name, that doesn’t match to package.

Lookup order:

  1. Ad-hoc aliases when nothing match

  2. Normalized name that starts with flake8

  3. Normalized name that starts with pep

  4. plugin_name

flakeheaven._logic.get_plugin_rules(plugin_name: str, plugins: Dict[str, List[str]]) List[str][source]

Get rules for plugin from plugins in the config

Plugin name can be specified as a glob expression. So, it’s not trivial to match the right one

  1. Try to find exact match (normalizing ass all packages names normalized)

  2. Try to find globs that match and select the longest one (nginx-style)

  3. Return empty list if nothing is found.

flakeheaven._logic.make_baseline(path: pathlib.Path, context: str, code: str, line: int) str[source]
flakeheaven._logic.prepare_cache(path=PosixPath('/home/docs/checkouts/readthedocs.org/user_builds/flakeheaven/checkouts/stable/docs/.flakeheaven_cache'))[source]
flakeheaven._logic.read_config(*paths) Dict[str, Any][source]

Submodules