Skip to content

Commit

Permalink
chore: make a couple more things frozen/hashable (#307)
Browse files Browse the repository at this point in the history
Manifest and Fpath were not marked with the decorator to make frozen
dataclasses, so were unhashable in Python. This adds the decorator to
make them
hashable.

- [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.17.0.
See
https://atd.readthedocs.io/en/latest/atdgen-tutorial.html#smooth-protocol-upgrades

Co-authored-by: Yoann Padioleau <[email protected]>
  • Loading branch information
bkettle and aryx authored Nov 4, 2024
1 parent 4156333 commit b690925
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions semgrep_output_v1.atd
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ type raw_json <ocaml module="Yojson.Basic" t="t"> = abstract
(*****************************************************************************)

(* File path. less: could convert directly to Path class of pathlib library for Python *)
type fpath <ocaml attr="deriving show"> = string wrap <ocaml module="ATD_string_wrap.Fpath">
type fpath <ocaml attr="deriving show"> <python decorator="dataclass(frozen=True)">= string wrap <ocaml module="ATD_string_wrap.Fpath">

type uri = string wrap <ocaml module="ATD_string_wrap.Uri">

Expand Down Expand Up @@ -1856,7 +1856,8 @@ type manifest_kind
(* pyproject.toml - https://packaging.python.org/en/latest/guides/writing-pyproject-toml/ *)
]

type manifest = {
type manifest
<python decorator="dataclass(frozen=True)"> = {
kind: manifest_kind;
path: fpath;
}
Expand Down
4 changes: 2 additions & 2 deletions semgrep_output_v1.py

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

0 comments on commit b690925

Please sign in to comment.