Parsers#
File format detection, parsing, and normalization.
Task file parser registry and auto-detection.
- class conda_tasks.parsers.TaskFileParser[source]#
Interface that every task file parser must implement.
- abstractmethod add_task(path: Path, name: str, task: Task) None[source]#
Persist a new task definition into path.
- abstractmethod can_handle(path: Path) bool[source]#
Return True if this parser knows how to read path.
- conda_tasks.parsers.detect_and_parse(file_path: Path | None = None, start_dir: Path | None = None) tuple[Path, dict[str, Task]][source]#
Detect (or use file_path) a task file and parse it.
Returns
(resolved_path, {task_name: Task}). RaisesNoTaskFileErrorwhen no file is found.
- conda_tasks.parsers.detect_task_file(start_dir: Path | None = None) Path | None[source]#
Walk up from start_dir looking for a known task file.
Returns the first match according to
_SEARCH_ORDER, orNone.
- conda_tasks.parsers.get_parser(path: Path) TaskFileParser | None[source]#
Return the first parser that can handle path, or
None.
Abstract base class for task file parsers.
- class conda_tasks.parsers.base.TaskFileParser[source]#
Interface that every task file parser must implement.
- abstractmethod add_task(path: Path, name: str, task: Task) None[source]#
Persist a new task definition into path.
- abstractmethod can_handle(path: Path) bool[source]#
Return True if this parser knows how to read path.
Parser for the conda.toml canonical TOML format.
Uses the same structure as pixi.toml tasks:
[tasks]
build = "make build"
test = { cmd = "pytest", depends-on = ["build"] }
[target.win-64.tasks]
build = "nmake build"
- class conda_tasks.parsers.toml.CondaTomlParser[source]#
Reads and writes
conda.tomlfiles.Structure is identical to pixi.toml task tables:
[tasks]for definitions,[target.<platform>.tasks]for overrides.
- conda_tasks.parsers.toml.tasks_to_toml(tasks: dict[str, Task]) str[source]#
Serialize a full task dict to
conda.tomlTOML string.
Parser for pixi.toml [tasks] and [target.<platform>.tasks] tables.
- class conda_tasks.parsers.pixi_toml.PixiTomlParser[source]#
Reads
pixi.tomltask definitions.Supports: -
[tasks]top-level table -[target.<platform>.tasks]per-platform overrides
Parser for pyproject.toml task definitions.
Reads from:
- [tool.conda.tasks] (preferred)
- [tool.conda-tasks.tasks] (legacy alias)
- [tool.pixi.tasks] (fallback for pixi compatibility)
Platform overrides:
- [tool.conda.target.<platform>.tasks]
- [tool.conda-tasks.target.<platform>.tasks]
- [tool.pixi.target.<platform>.tasks]
- class conda_tasks.parsers.pyproject_toml.PyprojectTomlParser[source]#
Reads task definitions from
pyproject.toml.- add_task(path: Path, name: str, task: Task) None[source]#
Not supported —
pyproject.tomlis read-only.
Parser for .condarc task definitions.
Reads task definitions from the plugins.conda_tasks.tasks section
of .condarc using conda’s configuration loading API. This means tasks
defined in any condarc source (user, system, environment) are automatically
discovered.
Writing (add/remove) still uses direct YAML manipulation since the config API is read-only.
- class conda_tasks.parsers.condarc.CondaRCParser[source]#
Reads task definitions from
.condarcvia conda’s config API.- add_task(path: Path, name: str, task: Task) None[source]#
Add or update a task under
plugins.conda_tasks.tasksin.condarc.
Shared logic for normalizing raw task dicts into Task model objects.
- conda_tasks.parsers.normalize.normalize_args(raw: list[Any] | None) list[TaskArg][source]#
Convert raw arg definitions into TaskArg objects.
Accepted shapes: -
["name"](required arg, no default) -[{"arg": "name", "default": "value"}]
- conda_tasks.parsers.normalize.normalize_depends_on(raw: list[Any] | str | None) list[TaskDependency][source]#
Convert the various
depends-onformats into TaskDependency objects.Accepted shapes: -
["foo", "bar"](simple list of task names) -[{"task": "foo", "args": ["x"]}, ...](full dict form) -[{"task": "foo"}, {"task": "bar"}](pixi alias shorthand)
- conda_tasks.parsers.normalize.normalize_override(raw: dict[str, Any]) TaskOverride[source]#
Parse a raw dict into a TaskOverride.
- conda_tasks.parsers.normalize.normalize_task(name: str, raw: str | list[Any] | dict[str, Any]) Task[source]#
Convert a single raw task value into a Task object.
Handles all the shorthand forms: -
"command string"(simple string command) -["dep1", "dep2"]or[{"task": ...}](alias / dependency-only) -{cmd: ..., depends-on: ..., ...}(full dict definition)