https://pantsbuild.org/ logo
#general
Title
# general
f

fresh-continent-76371

04/06/2023, 12:06 AM
I am working through tutorial here https://www.pantsbuild.org/docs/create-a-new-goal and (have not got to running the code) i suspect, unless there is magic sauce I am not familiar with, the example has a bug
Copy code
# project_version/targets.py
from pants.engine.target import COMMON_TARGET_FIELDS, SingleSourceField, Target


class ProjectVersionTarget(Target):
    alias = "version_file"
    core_fields = (*COMMON_TARGET_FIELDS, SingleSourceField)
    help = "A project version target representing the VERSION file."
Copy code
# project_version/register.py
from typing import Iterable

from pants.engine.target import Target
from project_version.target_types import ProjectVersionTarget   <<< incorrect import ?


def target_types() -> Iterable[type[Target]]:
    return [ProjectVersionTarget]
the import in the register example
from project_version.target_types import ProjectVersionTarget
should be
from project_version.targets import ProjectVersionTarget
w

wide-midnight-78598

04/06/2023, 12:50 AM
Looks like it could be a typo. the "convention" in the main repo is that those types of files live at
xyz/target_types.py
https://github.com/pantsbuild/pants/search?q=target_types