Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adopt schemaver #288

Merged
merged 9 commits into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,11 @@
"tasklist",
]
myst_linkify_fuzzy_links = False
default_config_payload = json.dumps(
json.loads(
(Path(__file__).parents[2] / "menuinst" / "data" / "menuinst.default.json").read_text()
),
indent=2,
)
latest_default = sorted(
(Path(__file__).parents[2] / "menuinst" / "data").glob("*-*.default.json"),
key=lambda path: [int(x) for x in path.name.split(".")[0].rsplit("-", 3)[-3:]],
)[-1]
default_config_payload = json.dumps(json.loads(latest_default.read_text()), indent=2)
myst_substitutions = {
"default_schema_json": f"```json\n{default_config_payload}\n```",
}
Expand Down
6 changes: 4 additions & 2 deletions menuinst/_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@

log = getLogger(__name__)
SCHEMA_DIALECT = "http://json-schema.org/draft-07/schema#"
SCHEMA_VERSION = "1"
# We follow schemaver
SCHEMA_VERSION = "1-1-0"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we always use the latest version here, similar to what you're doing in docs/source/conf.py?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'd run into a catch-22, because to bump it we'd need to first copy the latest file with a new name, and that feels clunky and hard to track via diffs and code reviews.

We could import from menuinst.platforms.base though, but I didn't do that because (1) we would start depending on the project itself, and so far this module was standalone, and (2) this feels like the natural place to define the schema version. That's why I "tied" these hardcoded values via a test instead.

What do you think? Would you consider this a blocker?

SCHEMA_URL = f"https://schemas.conda.org/menuinst-{SCHEMA_VERSION}.schema.json"


Expand Down Expand Up @@ -702,6 +703,7 @@ class Config(BaseModel.Config):
schema_extra = {
"$schema": SCHEMA_DIALECT,
"$id": SCHEMA_URL,
"$version": SCHEMA_VERSION,
}

id_: constr(min_length=1) = Field(
Expand All @@ -712,7 +714,7 @@ class Config(BaseModel.Config):
)
schema_: constr(min_length=1) = Field(
SCHEMA_URL,
description="Version of the menuinst schema.",
description="Version of the menuinst schema to validate against.",
alias="$schema",
)
menu_name: constr(min_length=1) = Field(
Expand Down
66 changes: 66 additions & 0 deletions menuinst/data/menuinst-1-0-0.default.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
{
"id_": "https://schemas.conda.io/menuinst-1.schema.json",
"schema_": "https://json-schema.org/draft-07/schema",
"menu_name": "REQUIRED",
"menu_items": [
{
"name": "REQUIRED",
"description": "REQUIRED",
"command": [
"REQUIRED"
],
"icon": null,
"precommand": null,
"precreate": null,
"working_dir": null,
"activate": true,
"terminal": false,
"platforms": {
"linux": {
"Categories": null,
"DBusActivatable": null,
"GenericName": null,
"Hidden": null,
"Implements": null,
"Keywords": null,
"MimeType": null,
"NoDisplay": null,
"NotShowIn": null,
"OnlyShowIn": null,
"PrefersNonDefaultGPU": null,
"StartupNotify": null,
"StartupWMClass": null,
"TryExec": null,
"glob_patterns": null
},
"osx": {
"CFBundleDisplayName": null,
"CFBundleIdentifier": null,
"CFBundleName": null,
"CFBundleSpokenName": null,
"CFBundleVersion": null,
"CFBundleURLTypes": null,
"CFBundleDocumentTypes": null,
"LSApplicationCategoryType": null,
"LSBackgroundOnly": null,
"LSEnvironment": null,
"LSMinimumSystemVersion": null,
"LSMultipleInstancesProhibited": null,
"LSRequiresNativeExecution": null,
"UTExportedTypeDeclarations": null,
"UTImportedTypeDeclarations": null,
"entitlements": null,
"link_in_bundle": null,
"event_handler": null
},
"win": {
"desktop": true,
"quicklaunch": true,
"url_protocols": null,
"file_extensions": null,
"app_user_model_id": null
}
}
}
]
}
Loading
Loading