Skip to content

Commit

Permalink
Complete the dependency_source type with MultiLockfile (#351)
Browse files Browse the repository at this point in the history
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!
  • Loading branch information
aryx authored Feb 18, 2025
1 parent 2a998e7 commit d0803ee
Show file tree
Hide file tree
Showing 7 changed files with 4,142 additions and 4,064 deletions.
13 changes: 13 additions & 0 deletions semgrep_output_v1.atd
Original file line number Diff line number Diff line change
Expand Up @@ -2239,13 +2239,26 @@ type lockfile
path: fpath;
}

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

(* alt: sca_error_kind *)
Expand Down
12 changes: 12 additions & 0 deletions semgrep_output_v1.jsonschema

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion semgrep_output_v1.proto

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit d0803ee

Please sign in to comment.