style.StyleDiffRule
Base class for a diff rule: flags constructs newly introduced by the change.
Usage
style.StyleDiffRule()Like [StyleRule][captain_hook.style.StyleRule], but it compares the pre-edit and post-edit trees. The declarative form flags nodes matching match in the new tree that were absent from the old tree (by unparsed source); override check when the “newly introduced” identity needs custom logic.
Example
from captain_hook.style import matchers as M
class NoNewWildcardImport(StyleDiffRule):
"""Wildcard import added by this edit: {violations}"""
match = M.imports.where(lambda n: any(a.name == "*" for a in n.names))