lint package
Submodules
lint.config module
- lint.config.DEFAULT_LINTER_CONFIG_SCHEMA = {'additionalProperties': False, 'patternProperties': {'^[A-Z][a-zA-Z0-9]*$': {'properties': {'enabled': {'type': 'boolean'}}, 'required': ['enabled'], 'type': 'object'}}, 'type': 'object'}
The default schema for a linter config, which enforces that lint rule names are PascalCase and that each lint rule config satisfies its default schema
- lint.config.DEFAULT_LINT_RULE_CONFIG_SCHEMA = {'properties': {'enabled': {'type': 'boolean'}}, 'required': ['enabled'], 'type': 'object'}
The default lint rule config schema, which enforces that lint rule config dicts have a boolean property named enabled
- class lint.config.LintRuleConfig(config: dict[str, Any], schema: dict[str, Any] = {'properties': {'enabled': {'type': 'boolean'}}, 'required': ['enabled'], 'type': 'object'})
Bases:
Generic[T]The LintRuleConfig class represents the configuration for a lint rule
- enabled() bool
Determines whether the lint rule is enabled
- Returns:
Whether the lint rule is enabled
- Return type:
bool
- validate() tuple[bool, str]
Validates a LintRuleConfig instance
- Returns:
Whether the config dict was valid str: Error message if the config dict was invalid
- Return type:
bool
- static validate_static(config: dict[str, Any], schema: dict[str, Any] = {'properties': {'enabled': {'type': 'boolean'}}, 'required': ['enabled'], 'type': 'object'}) tuple[bool, str]
Validates a LintRuleConfig dictionary
- Parameters:
config (dict) – The lint rule config dictionary
schema (dict) – The lint rule config dictionary
- Returns:
Whether the lint rule config dict was valid str: Error message if the config dict was invalid
- Return type:
bool
- class lint.config.LinterConfig(config: dict[str, Any], schema: dict[str, Any] = {'additionalProperties': False, 'patternProperties': {'^[A-Z][a-zA-Z0-9]*$': {'properties': {'enabled': {'type': 'boolean'}}, 'required': ['enabled'], 'type': 'object'}}, 'type': 'object'})
Bases:
Generic[T]The LinterConfig class represents the configuration for a linter
- enabled(rule: str) bool
Determines whether a given lint rule is enabled in the lint config
- Parameters:
rule (str) – The name of the lint rule
- Returns:
Whether the lint rule is enabled
- Return type:
bool
- validate() tuple[bool, str]
Validates a LinterConfig instance
- Returns:
Whether the config dict was valid str: Error message if the config dict was invalid
- Return type:
bool
- static validate_static(config: dict[str, Any], schema: dict[str, Any] = {'additionalProperties': False, 'patternProperties': {'^[A-Z][a-zA-Z0-9]*$': {'properties': {'enabled': {'type': 'boolean'}}, 'required': ['enabled'], 'type': 'object'}}, 'type': 'object'}) tuple[bool, str]
Validates a LinterConfig dictionary
- Parameters:
config (dict) – The linter config dictionary
schema (dict) – The linter config JSON schema dictionary
- Returns:
Whether the config dict was valid str: Error message if the config dict was invalid
- Return type:
bool
lint.linter module
- class lint.linter.Linter(rules: list[LintRule[T]])
Bases:
Generic[T]The Linter class applies potentially multiple lint rules against an artifact, returning the list of lint results for each enforced rule
- lint(artifact: ~lint.typing.T, config: ~lint.config.LinterConfig[~lint.typing.T] = <lint.config.LinterConfig object>, **kwargs) list[LintResult]
Applies the linter’s lint rules against an artifact, returning the list of lint results for each enforced rule
- Parameters:
artifact (T) – The artifact to lint
config (LinterConfig) – The configuration for the linter
- Returns:
The list of LintResults corresponding to each lint rule
- Return type:
list
lint.result module
- class lint.result.LintResult(status: LintStatus = LintStatus.INFO, message: str = '')
Bases:
objectThe LintResult class represents the result of a lint rule after the rule has been enforced against an artifact. It includes a LintStatus indicating the severity of the result, and a message represented as a string.
lint.rule module
- class lint.rule.LintRule
Bases:
Generic[T]The LintRule class represents a rule that can be enforced against an artifact. When enforced, it produces a LintResult which describes the outcome of enforcing the rule.
- lint(artifact: ~lint.typing.T, config: ~lint.config.LintRuleConfig[~lint.typing.T] = <lint.config.LintRuleConfig object>, **kwargs) LintResult
Enforces the lint rule against an artifact
- Parameters:
artifact (T) – An artifact to lint
config (LintRuleConfig) – The configuration for this lint rule
- Returns:
The lint result
- Return type:
- name() str
Returns the name of the lint rule
- Returns:
The name of the lint rule
- Return type:
str
lint.status module
- class lint.status.LintStatus(*values)
Bases:
EnumThe LintStatus enum represents the status or severity of a lint rule’s result after the rule is enforced against an artifact.
- ERROR = 2
- INFO = 0
- WARNING = 1
- static try_from_name(name: str) tuple[LintStatus | None, str]
Try to load a LintStatus from its name property serialized as a string
- Parameters:
name (str) – The name of the LintStatus enum
- Returns:
The loaded LintStatus, or None if not loaded str: Error message if the LintStatus was not loaded successfully
- Return type:
- static try_from_value(value: int) tuple[LintStatus | None, str]
Try to load a LintStatus from its value property serialized as an int
Args: value (int): The value of the LintStatus enum
- Returns:
The loaded LintStatus, or None if not loaded str: Error message if the LintStatus was not loaded successfully
- Return type: