flakeheaven._logic._plugin

flakeheaven._logic._plugin.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._plugin.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._plugin.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._plugin.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.