-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sketch validation for simple type checks
- Loading branch information
1 parent
183259b
commit 3568635
Showing
6 changed files
with
63 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,23 @@ | ||
from typing import Any | ||
|
||
from hatchling.bridge.app import Application | ||
from hatchling.builders.config import BuilderConfigBound | ||
|
||
from hatchling.builders.hooks.plugin.interface import BuildHookInterface | ||
from hatchling.metadata.core import ProjectMetadata | ||
|
||
|
||
class WebAssetsBuildHook(BuildHookInterface): | ||
class WebAssetsBuildHook(BuildHookInterface[BuilderConfigBound]): | ||
PLUGIN_NAME = "web_assets" | ||
|
||
def __init__(self, root: str, config: dict[str, Any], build_config: BuilderConfigBound, metadata: ProjectMetadata, | ||
directory: str, target_name: str, app: Application | None = None) -> None: | ||
super().__init__(root, config, build_config, metadata, directory, target_name, app) | ||
# def __init__( | ||
# self, | ||
# root: str, | ||
# config: dict[str, Any], | ||
# build_config: BuilderConfigBound, | ||
# metadata: ProjectMetadata[PluginManagerBound], | ||
# directory: str, | ||
# target_name: str, | ||
# app: Application | None = None | ||
# ) -> None: | ||
# super().__init__(root, config, build_config, metadata, directory, target_name, app) | ||
|
||
def initialize(self, version: str, build_data: dict[str, Any]) -> None: | ||
super().initialize(version, build_data) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
# SPDX-FileCopyrightText: 2024-present Dylan Lukes <[email protected]> | ||
# | ||
# SPDX-License-Identifier: BSD-3-Clause | ||
import itertools as it | ||
|
||
import pytest | ||
|
||
import renkon.api as rk | ||
|
@@ -23,3 +25,19 @@ def test_sketch_bindings_extra(): | |
def test_sketch_linear2(): | ||
schema = Schema({"time": rk.float_(), "open tabs": rk.float_()}) | ||
TraitSketch(spec=Linear2.spec, schema=schema, bindings={"X": "time", "Y": "open tabs"}) | ||
|
||
|
||
def test_sketch_incorrect_typing(): | ||
schema = Schema({"x": rk.int_(), "name": rk.str_()}) | ||
with pytest.raises(TypeError, match="incompatible type"): | ||
TraitSketch(spec=Linear2.spec, schema=schema, bindings={"X": "x", "Y": "name"}) | ||
|
||
|
||
def test_sketch_typevars(): | ||
for ty1, ty2 in it.product(rk.equatable().ts, repeat=2): | ||
schema = Schema({"a": ty1, "b": ty2}) | ||
if ty1 == ty2: | ||
TraitSketch(spec=Equal.spec, schema=schema, bindings={"A": "a", "B": "b"}) | ||
else: | ||
with pytest.raises(TypeError): | ||
TraitSketch(spec=Equal.spec, schema=schema, bindings={"A": "a", "B": "b"}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# SPDX-FileCopyrightText: 2024-present Dylan Lukes <[email protected]> | ||
# | ||
# SPDX-License-Identifier: BSD-3-Clause | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# SPDX-FileCopyrightText: 2024-present Dylan Lukes <[email protected]> | ||
# | ||
# SPDX-License-Identifier: BSD-3-Clause |