mirror of
https://github.com/TinyTapeout/tt-support-tools.git
synced 2026-11-02 20:26:10 +01:00
fix(project): only require non-empty pinout with --check-docs
This commit is contained in:
+1
-1
@@ -41,7 +41,7 @@ def check_info_yaml(project_dir: str, pdk: str) -> list[str]:
|
||||
tile_sizes = yaml.safe_load(f)
|
||||
|
||||
try:
|
||||
_ = ProjectInfo(yaml_data, tile_sizes)
|
||||
_ = ProjectInfo(yaml_data, tile_sizes, require_pinout=True)
|
||||
except Exception as e:
|
||||
if isinstance(e, ProjectYamlError):
|
||||
return e.errors
|
||||
|
||||
+11
-4
@@ -12,14 +12,16 @@ class ProjectYamlError(Exception):
|
||||
|
||||
|
||||
class PinoutSection:
|
||||
def __init__(self, yaml_data: Dict[str, Any], errors: List[str]):
|
||||
def __init__(
|
||||
self, yaml_data: Dict[str, Any], errors: List[str], require_pinout: bool = False
|
||||
):
|
||||
self.__nonEmptyPins = 0
|
||||
yaml_data = yaml_data.copy()
|
||||
self.ui = self._pins(yaml_data, "ui", 8, errors)
|
||||
self.uo = self._pins(yaml_data, "uo", 8, errors)
|
||||
self.uio = self._pins(yaml_data, "uio", 8, errors)
|
||||
self.ua = self._pins(yaml_data, "ua", 6, errors, True)
|
||||
if self.__nonEmptyPins == 0:
|
||||
if require_pinout and self.__nonEmptyPins == 0:
|
||||
errors.append("Please fill in the 'pinout' section")
|
||||
if len(yaml_data) > 0:
|
||||
errors.append(
|
||||
@@ -55,7 +57,12 @@ class ProjectInfo:
|
||||
top_module: str
|
||||
source_files: List[str]
|
||||
|
||||
def __init__(self, yaml_data: Dict[str, Any], tile_sizes: Dict[str, str]):
|
||||
def __init__(
|
||||
self,
|
||||
yaml_data: Dict[str, Any],
|
||||
tile_sizes: Dict[str, str],
|
||||
require_pinout: bool = False,
|
||||
):
|
||||
errors: List[str] = []
|
||||
|
||||
# Validate Version
|
||||
@@ -179,7 +186,7 @@ class ProjectInfo:
|
||||
if "pinout" not in yaml_data:
|
||||
errors.append("Missing 'pinout' section")
|
||||
else:
|
||||
self.pinout = PinoutSection(yaml_data["pinout"], errors)
|
||||
self.pinout = PinoutSection(yaml_data["pinout"], errors, require_pinout)
|
||||
|
||||
# Optional fields
|
||||
self.discord: Optional[str] = project_section.get("discord")
|
||||
|
||||
+10
-1
@@ -315,7 +315,16 @@ class TestProjectInfoPinoutSection:
|
||||
with pytest.raises(
|
||||
ProjectYamlError, match="Please fill in the 'pinout' section"
|
||||
):
|
||||
ProjectInfo(valid_yaml_data, tile_sizes)
|
||||
ProjectInfo(valid_yaml_data, tile_sizes, require_pinout=True)
|
||||
|
||||
def test_all_empty_pinout_allowed_without_require_pinout(
|
||||
self, valid_yaml_data, tile_sizes
|
||||
):
|
||||
for pin in valid_yaml_data["pinout"]:
|
||||
valid_yaml_data["pinout"][pin] = ""
|
||||
# Should not raise an error when require_pinout is False (default)
|
||||
info = ProjectInfo(valid_yaml_data, tile_sizes)
|
||||
assert info.pinout is not None
|
||||
|
||||
def test_invalid_pinout_keys(self, valid_yaml_data, tile_sizes):
|
||||
valid_yaml_data["pinout"]["invalid_key"] = "value"
|
||||
|
||||
Reference in New Issue
Block a user