Skip to content

Commit b690925

Browse files
bkettlearyx
andauthored
chore: make a couple more things frozen/hashable (#307)
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]>
1 parent 4156333 commit b690925

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

semgrep_output_v1.atd

+3-2
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ type raw_json <ocaml module="Yojson.Basic" t="t"> = abstract
7171
(*****************************************************************************)
7272

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

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

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

1859-
type manifest = {
1859+
type manifest
1860+
<python decorator="dataclass(frozen=True)"> = {
18601861
kind: manifest_kind;
18611862
path: fpath;
18621863
}

semgrep_output_v1.py

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)