Documentation
¶
Index ¶
- Variables
- type Check
- type CheckContext
- type CheckResult
- type ConfigDeprecatedFieldsCheck
- func (c *ConfigDeprecatedFieldsCheck) Check(ctx *CheckContext) ([]Finding, error)
- func (c *ConfigDeprecatedFieldsCheck) Description() string
- func (c *ConfigDeprecatedFieldsCheck) Fix(_ *CheckContext, _ []Finding) error
- func (c *ConfigDeprecatedFieldsCheck) Group() Group
- func (c *ConfigDeprecatedFieldsCheck) Name() string
- type ConfigParseCheck
- type ConfigPredictRefCheck
- type ConfigSchemaCheck
- type DeprecatedImportsCheck
- func (c *DeprecatedImportsCheck) Check(ctx *CheckContext) ([]Finding, error)
- func (c *DeprecatedImportsCheck) Description() string
- func (c *DeprecatedImportsCheck) Fix(ctx *CheckContext, findings []Finding) error
- func (c *DeprecatedImportsCheck) Group() Group
- func (c *DeprecatedImportsCheck) Name() string
- type DockerCheck
- type Finding
- type Group
- type MissingTypeAnnotationsCheck
- func (c *MissingTypeAnnotationsCheck) Check(ctx *CheckContext) ([]Finding, error)
- func (c *MissingTypeAnnotationsCheck) Description() string
- func (c *MissingTypeAnnotationsCheck) Fix(_ *CheckContext, _ []Finding) error
- func (c *MissingTypeAnnotationsCheck) Group() Group
- func (c *MissingTypeAnnotationsCheck) Name() string
- type ParsedFile
- type PydanticBaseModelCheck
- func (c *PydanticBaseModelCheck) Check(ctx *CheckContext) ([]Finding, error)
- func (c *PydanticBaseModelCheck) Description() string
- func (c *PydanticBaseModelCheck) Fix(ctx *CheckContext, findings []Finding) error
- func (c *PydanticBaseModelCheck) Group() Group
- func (c *PydanticBaseModelCheck) Name() string
- type PythonVersionCheck
- type Result
- type RunOptions
- type Severity
Constants ¶
This section is empty.
Variables ¶
var ErrNoAutoFix = errors.New("no auto-fix available for this check")
ErrNoAutoFix is returned by Fix() for detect-only checks.
Functions ¶
This section is empty.
Types ¶
type Check ¶
type Check interface {
Name() string
Group() Group
Description() string
Check(ctx *CheckContext) ([]Finding, error)
Fix(ctx *CheckContext, findings []Finding) error
}
Check is the interface every doctor rule implements.
type CheckContext ¶
type CheckContext struct {
ProjectDir string
ConfigFilename string // Config filename (e.g. "cog.yaml")
Config *config.Config // Parsed cog.yaml (nil if parsing failed)
ConfigFile []byte // Raw cog.yaml bytes (available even if parsing failed)
LoadResult *config.LoadResult // Non-nil if config loaded successfully
LoadErr error // Non-nil if config loading failed
PythonFiles map[string]*ParsedFile // Pre-parsed Python files keyed by relative path
PythonPath string // Path to python binary (empty if not found)
// contains filtered or unexported fields
}
CheckContext provides checks with access to project state. Built once by the runner and passed to every check.
The ctx field deliberately stores a context.Context, which deviates from the usual Go guidance of passing contexts as the first argument to every function. It's kept unexported to discourage external callers from constructing a CheckContext directly — all production construction goes through buildCheckContext, which always populates ctx. Tests in this package set ctx explicitly via struct literals.
func (*CheckContext) Close ¶
func (cc *CheckContext) Close()
Close releases resources held by the CheckContext — primarily the C-allocated tree-sitter parse trees cached in PythonFiles. Tree-sitter also releases memory via runtime finalizers, but calling Close() on each tree releases the backing buffer promptly, which matters if the doctor runner is reused from a long-lived process.
type CheckResult ¶
type CheckResult struct {
Check Check
Findings []Finding
Fixed bool // True if --fix was passed and Fix() succeeded
Err error // Non-nil if the check itself errored
}
CheckResult holds the outcome of running a single check.
type ConfigDeprecatedFieldsCheck ¶
type ConfigDeprecatedFieldsCheck struct{}
ConfigDeprecatedFieldsCheck detects deprecated fields in cog.yaml.
func (*ConfigDeprecatedFieldsCheck) Check ¶
func (c *ConfigDeprecatedFieldsCheck) Check(ctx *CheckContext) ([]Finding, error)
func (*ConfigDeprecatedFieldsCheck) Description ¶
func (c *ConfigDeprecatedFieldsCheck) Description() string
func (*ConfigDeprecatedFieldsCheck) Fix ¶
func (c *ConfigDeprecatedFieldsCheck) Fix(_ *CheckContext, _ []Finding) error
func (*ConfigDeprecatedFieldsCheck) Group ¶
func (c *ConfigDeprecatedFieldsCheck) Group() Group
func (*ConfigDeprecatedFieldsCheck) Name ¶
func (c *ConfigDeprecatedFieldsCheck) Name() string
type ConfigParseCheck ¶
type ConfigParseCheck struct{}
ConfigParseCheck verifies that cog.yaml exists and can be parsed as valid YAML.
func (*ConfigParseCheck) Check ¶
func (c *ConfigParseCheck) Check(ctx *CheckContext) ([]Finding, error)
func (*ConfigParseCheck) Description ¶
func (c *ConfigParseCheck) Description() string
func (*ConfigParseCheck) Fix ¶
func (c *ConfigParseCheck) Fix(_ *CheckContext, _ []Finding) error
func (*ConfigParseCheck) Group ¶
func (c *ConfigParseCheck) Group() Group
func (*ConfigParseCheck) Name ¶
func (c *ConfigParseCheck) Name() string
type ConfigPredictRefCheck ¶
type ConfigPredictRefCheck struct{}
ConfigPredictRefCheck verifies that the predict field in cog.yaml points to a file and class that actually exist.
func (*ConfigPredictRefCheck) Check ¶
func (c *ConfigPredictRefCheck) Check(ctx *CheckContext) ([]Finding, error)
func (*ConfigPredictRefCheck) Description ¶
func (c *ConfigPredictRefCheck) Description() string
func (*ConfigPredictRefCheck) Fix ¶
func (c *ConfigPredictRefCheck) Fix(_ *CheckContext, _ []Finding) error
func (*ConfigPredictRefCheck) Group ¶
func (c *ConfigPredictRefCheck) Group() Group
func (*ConfigPredictRefCheck) Name ¶
func (c *ConfigPredictRefCheck) Name() string
type ConfigSchemaCheck ¶
type ConfigSchemaCheck struct{}
ConfigSchemaCheck validates cog.yaml against the configuration schema. Parse errors are handled by ConfigParseCheck; this check catches schema and validation errors (wrong types, invalid values, etc.).
func (*ConfigSchemaCheck) Check ¶
func (c *ConfigSchemaCheck) Check(ctx *CheckContext) ([]Finding, error)
func (*ConfigSchemaCheck) Description ¶
func (c *ConfigSchemaCheck) Description() string
func (*ConfigSchemaCheck) Fix ¶
func (c *ConfigSchemaCheck) Fix(_ *CheckContext, _ []Finding) error
func (*ConfigSchemaCheck) Group ¶
func (c *ConfigSchemaCheck) Group() Group
func (*ConfigSchemaCheck) Name ¶
func (c *ConfigSchemaCheck) Name() string
type DeprecatedImportsCheck ¶
type DeprecatedImportsCheck struct{}
DeprecatedImportsCheck detects imports that were removed or moved in recent cog versions.
func (*DeprecatedImportsCheck) Check ¶
func (c *DeprecatedImportsCheck) Check(ctx *CheckContext) ([]Finding, error)
func (*DeprecatedImportsCheck) Description ¶
func (c *DeprecatedImportsCheck) Description() string
func (*DeprecatedImportsCheck) Fix ¶
func (c *DeprecatedImportsCheck) Fix(ctx *CheckContext, findings []Finding) error
func (*DeprecatedImportsCheck) Group ¶
func (c *DeprecatedImportsCheck) Group() Group
func (*DeprecatedImportsCheck) Name ¶
func (c *DeprecatedImportsCheck) Name() string
type DockerCheck ¶
type DockerCheck struct{}
DockerCheck verifies that Docker is installed and the daemon is reachable.
func (*DockerCheck) Check ¶
func (c *DockerCheck) Check(ctx *CheckContext) ([]Finding, error)
func (*DockerCheck) Description ¶
func (c *DockerCheck) Description() string
func (*DockerCheck) Fix ¶
func (c *DockerCheck) Fix(_ *CheckContext, _ []Finding) error
func (*DockerCheck) Group ¶
func (c *DockerCheck) Group() Group
func (*DockerCheck) Name ¶
func (c *DockerCheck) Name() string
type Finding ¶
type Finding struct {
Severity Severity
Message string // What's wrong
Remediation string // How to fix it
File string // Optional: file path where the issue was found
Line int // Optional: line number (1-indexed, 0 means unknown)
}
Finding represents a single problem detected by a check.
type MissingTypeAnnotationsCheck ¶
type MissingTypeAnnotationsCheck struct{}
MissingTypeAnnotationsCheck detects predict/train methods that are missing return type annotations.
func (*MissingTypeAnnotationsCheck) Check ¶
func (c *MissingTypeAnnotationsCheck) Check(ctx *CheckContext) ([]Finding, error)
func (*MissingTypeAnnotationsCheck) Description ¶
func (c *MissingTypeAnnotationsCheck) Description() string
func (*MissingTypeAnnotationsCheck) Fix ¶
func (c *MissingTypeAnnotationsCheck) Fix(_ *CheckContext, _ []Finding) error
func (*MissingTypeAnnotationsCheck) Group ¶
func (c *MissingTypeAnnotationsCheck) Group() Group
func (*MissingTypeAnnotationsCheck) Name ¶
func (c *MissingTypeAnnotationsCheck) Name() string
type ParsedFile ¶
type ParsedFile struct {
Path string // Relative path from project root
Source []byte // Raw file contents
Tree *sitter.Tree // Tree-sitter parse tree
Imports *schema.ImportContext // Collected imports
}
ParsedFile holds tree-sitter parse results for a Python file.
type PydanticBaseModelCheck ¶
type PydanticBaseModelCheck struct{}
PydanticBaseModelCheck detects output classes that inherit from pydantic.BaseModel with arbitrary_types_allowed=True instead of using cog.BaseModel.
func (*PydanticBaseModelCheck) Check ¶
func (c *PydanticBaseModelCheck) Check(ctx *CheckContext) ([]Finding, error)
func (*PydanticBaseModelCheck) Description ¶
func (c *PydanticBaseModelCheck) Description() string
func (*PydanticBaseModelCheck) Fix ¶
func (c *PydanticBaseModelCheck) Fix(ctx *CheckContext, findings []Finding) error
func (*PydanticBaseModelCheck) Group ¶
func (c *PydanticBaseModelCheck) Group() Group
func (*PydanticBaseModelCheck) Name ¶
func (c *PydanticBaseModelCheck) Name() string
type PythonVersionCheck ¶
type PythonVersionCheck struct{}
PythonVersionCheck verifies that Python is available and that the local version is consistent with the version configured in cog.yaml.
func (*PythonVersionCheck) Check ¶
func (c *PythonVersionCheck) Check(ctx *CheckContext) ([]Finding, error)
func (*PythonVersionCheck) Description ¶
func (c *PythonVersionCheck) Description() string
func (*PythonVersionCheck) Fix ¶
func (c *PythonVersionCheck) Fix(_ *CheckContext, _ []Finding) error
func (*PythonVersionCheck) Group ¶
func (c *PythonVersionCheck) Group() Group
func (*PythonVersionCheck) Name ¶
func (c *PythonVersionCheck) Name() string
type Result ¶
type Result struct {
Results []CheckResult
}
Result holds the outcome of a full doctor run.
func (*Result) HasErrors ¶
HasErrors returns true if any check produced error-severity findings or if any check itself errored.
func (*Result) HasFixableErrors ¶
HasFixableErrors returns true if any check produced unfixed error-severity findings AND the check supports auto-fix. This helps the CLI decide whether suggesting --fix would actually be useful.
type RunOptions ¶
type RunOptions struct {
Fix bool
ProjectDir string
ConfigFilename string // Config filename (defaults to "cog.yaml" if empty)
}
RunOptions configures a doctor run.