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
- property results¶
returns cached checks results for the given file
- flakeheaven._logic.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.colored(text: object, color: str, attrs: Optional[List[str]] = None) str [source]¶
termcolor.colored implementation on top of colorama
- 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:
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.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:
Ad-hoc aliases when nothing match
Normalized name that starts with flake8
Normalized name that starts with pep
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
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.
- 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]¶