flakeheaven._logic._plugin¶
- flakeheaven._logic._plugin.check_include(code: str, rules: List[str]) bool [source]¶
Validate rules
Return True if rule explicitly included
Return False if rule explicitly excluded
Return True if the latest glob-matching rule is include
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:
Try to find exact match (normalizing as all packages names normalized)
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:
Ad-hoc aliases when nothing match
Normalized name that starts with flake8
Normalized name that starts with pep
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
Try to find exact match (normalizing ass all packages names normalized)
Try to find globs that match and select the longest one (nginx-style)
Return empty list if nothing is found.