-
-
Notifications
You must be signed in to change notification settings - Fork 608
/
dependency_inference.py
48 lines (32 loc) · 1.44 KB
/
dependency_inference.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# Copyright 2022 Pants project contributors (see CONTRIBUTORS.md).
# Licensed under the Apache License, Version 2.0 (see LICENSE).
from __future__ import annotations
from dataclasses import dataclass
from pants.build_graph.address import Address
from pants.engine.unions import union
from pants.util.frozendict import FrozenDict
@union
@dataclass(frozen=True)
class GoModuleImportPathsMappingsHook:
"""An entry point for a specific implementation of mapping Go import paths to owning targets.
All implementations will be merged together. The core Go dependency inference rules will request
the `GoModuleImportPathsMappings` type using implementations of this union.
"""
@dataclass(frozen=True)
class GoImportPathsMappingAddressSet:
addresses: tuple[Address, ...]
infer_all: bool
@dataclass(frozen=True)
class GoModuleImportPathsMapping:
"""Maps import paths (as strings) to one or more addresses of targets providing those import
path(s) for a single Go module."""
mapping: FrozenDict[str, GoImportPathsMappingAddressSet]
@dataclass(frozen=True)
class GoModuleImportPathsMappings:
"""Import path mappings for all Go modules in the repository.
This type is requested from plugins which provide implementations for the GoCodegenBuildRequest
union and then merged.
"""
modules: FrozenDict[Address, GoModuleImportPathsMapping]
class AllGoModuleImportPathsMappings(GoModuleImportPathsMappings):
pass