Python Style
Testing & Qualitypython-stylePython Style is an Agent Skill for testing & quality published in the open-edge-platform/anomalib repository on GitHub: a SKILL.md instruction file an AI agent can load to do this task.
Reviews anomalib Python style, typing, imports, and public API conventions
QUICK START
How to use this skill
Bring this guide into your coding agent with a prompt tailored to the tool you use.
- Open your project in Codex.
- Copy and paste the prompt below.
- Review files and risks before approving any action.
Prompt to paste
Inspect the Agent Skill at https://github.com/open-edge-platform/anomalib/blob/HEAD/.agents/skills/python-style/SKILL.md and all supporting files. Report provenance, permissions, scripts, dependencies, and security risks. Propose an exact installation into .agents/skills/python-style, but wait for my approval before writing files or running scripts.
Copying this prompt does not install or run the skill. Review third-party files before use.
Anomalib Python Style Review
Use this skill when reviewing Python code in src/anomalib/ or tests/.
Purpose and scope
This skill covers Python style, typing, imports, exports, copyright headers, and basic code hygiene.
Core rules
- Target the repository's Python baseline.
- Follow the Ruff-configured line length of 120 characters.
- Match nearby anomalib code before suggesting stylistic rewrites.
- Prefer explicit, readable code over clever shortcuts.
Request changes when
- public APIs are missing type annotations;
- new code introduces weak typing such as unnecessary
Anyor untyped public**kwargs; - imports or exports drift from nearby package patterns;
- a touched Python file is missing the expected copyright/SPDX header;
- error handling becomes less explicit or debug code is left behind.
Typing
- Public functions, methods, and constructors should have explicit type annotations.
- Prefer repository-established typing patterns such as
X | None,type[...],Sequence[...],TypeVar, andGenericwhere they fit. - Do not weaken types without a strong reason.
- Flag vague escape hatches such as unnecessary
Any, broad untyped**kwargs, or type suppressions that hide real issues.
Imports and exports
- Keep imports grouped as standard library, third-party, then local imports.
- Prefer absolute imports inside
anomalib. - When a public symbol is added to an
__init__.py, verify that__all__stays accurate.
Copyright and license header
- Python source files should include the standard Intel copyright and SPDX header used across the repository.
- For a new file, use the current year only, for example:
# Copyright (C) 2026 Intel Corporation# SPDX-License-Identifier: Apache-2.0
- For an existing file updated in 2026, ensure the year or year range includes 2026.
- Example: update
2024to2024-2026. - Example: keep
2026for a single-year file created in 2026.
- Example: update
Error handling and code hygiene
- Catch specific exceptions instead of broad or silent failure patterns.
- Ask for explicit exceptions and informative error messages.
- Flag debug prints, dead code, commented-out code, and magic values that should be named constants or config.
- Prefer explicit validation with raised exceptions over fragile assumptions.
Repo-grounded review anchors
pyproject.tomldefines Ruff, pydocstyle, mypy, pytest, and Commitizen expectations.
Reviewer checklist
- Check typing on public APIs.
- Check imports and exports.
- Check the copyright/SPDX header on touched Python files.
- Check for obvious code hygiene regressions.