Registry
Module containing registered rules and functions to update/discover them.
Info
Provided functions do not change the registry contents as it is managed automatically during rule
creation.
Tip
When creating custom linter, you should check lintkit.registry.inject
function for an option to easily pass configuration data.
lintkit.registry.codes ¶
Get all registered rule codes.
Returns:
Type | Description |
---|---|
tuple[int, ...] | A tuple of all registered rule codes. |
lintkit.registry.rules ¶
Get all registered rules.
Returns:
Type | Description |
---|---|
tuple[Rule, ...] | A tuple of all registered rules. |
lintkit.registry.inject ¶
Inject an attribute into all rules.
Tip
This is useful for injecting custom attributes into all rules, such as a custom configuration or a shared resource.
Example:
import lintkit
config = {"example": "value"}
# Now all rules can access config and use it
lintkit.registry.inject("config", config)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
attribute | str | The name of the attribute to inject. | required |
value | Any | The value to inject. | required |
Source code in src/lintkit/registry.py
lintkit.registry.query ¶
Query the registry for rules.
Warning
exclude
takes precedence over include
Example:
import lintkit
for rule in lintkit.registry.query(exclude_codes=[1, 2, 3]):
print(rule.code, rule.description)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
include_codes | Iterable[int] | None | The codes of the rules to include, if any. | None |
exclude_codes | Iterable[int] | None | The codes of the rules to exclude, if any. (takes precedence over | None |
Returns:
Type | Description |
---|---|
Iterator[Rule] | An iterator over the rules that match the query. |