Skip to content

Commit d0803ee

Browse files
authored
Complete the dependency_source type with MultiLockfile (#351)
The goal is to remove the redundancy between the type defs in the .atd and in subproject.py (which will help migrate the code from subproject.py to a new Subproject.ml) test plan: see related PR in semgrep - [x] I ran `make setup && make` to update the generated code after editing a `.atd` file (TODO: have a CI check) - [x] I made sure we're still backward compatible with old versions of the CLI. For example, the Semgrep backend need to still be able to *consume* data generated by Semgrep 1.50.0. See https://atd.readthedocs.io/en/latest/atdgen-tutorial.html#smooth-protocol-upgrades Note that the types related to the semgrep-core JSON output or the semgrep-core RPC do not need to be backward compatible!
1 parent 2a998e7 commit d0803ee

7 files changed

+4142
-4064
lines changed

semgrep_output_v1.atd

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2239,13 +2239,26 @@ type lockfile
22392239
path: fpath;
22402240
}
22412241

2242+
(* TODO? use a record instead of an ADT? *)
22422243
type dependency_source
22432244
<ocaml attr="deriving show">
22442245
<python decorator="dataclass(frozen=True)"> =
22452246
[
22462247
| ManifestOnlyDependencySource of manifest
22472248
| LockfileOnlyDependencySource of lockfile
22482249
| ManifestLockfileDependencySource of (manifest * lockfile)
2250+
(* The dependency_source should be LockfileOnly or ManifestLockfile,
2251+
* but not ManifestOnlyDependencySource.
2252+
* Right now this variant is only used by pysemgrep; it is
2253+
* deconstructed in multiple LockfileXxx when calling the dynamic resolver.
2254+
* Note that this variant introduces a series of problems in the Python code
2255+
* because atdpy generates a List[DependencySource] and List are
2256+
* not hashable in Python. We had to define a special hash function
2257+
* for Subproject to avoid hashing the dependency_source.
2258+
* TODO? add a <python repr="tuple"> so the list is converted instead in a
2259+
* Tuple[DependencySource, ...] which is hashable.
2260+
*)
2261+
| MultiLockfileDependencySource of dependency_source list
22492262
] <ocaml repr="classic">
22502263

22512264
(* alt: sca_error_kind *)

semgrep_output_v1.jsonschema

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

semgrep_output_v1.proto

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)