Skip to content

Commit

Permalink
fix: consolidate summary and layout types from exposing SnapMetadata
Browse files Browse the repository at this point in the history
Pyright started finding issues after exposing the symbol

Signed-off-by: Sergio Schvezov <sergio.schvezov@canonical.com>
  • Loading branch information
sergiusens committed Feb 14, 2024
1 parent d4e948f commit 296079f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion requirements-devel.txt
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ pyparsing==3.1.1
pyproject-api==1.6.1
pyramid==2.0.2
pyRFC3339==1.1
pyright==1.1.349
pyright==1.1.350
pytest==7.4.4
pytest-cov==4.1.0
pytest-mock==3.12.0
Expand Down
12 changes: 7 additions & 5 deletions snapcraft/meta/snap_yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

import pydantic
import yaml
from craft_application.models import BaseMetadata, constraints
from craft_application.models import BaseMetadata, SummaryStr, constraints
from craft_cli import emit
from pydantic import ValidationError, validator
from typing_extensions import override
Expand Down Expand Up @@ -229,7 +229,7 @@ class SnapMetadata(SnapcraftMetadata):
name: str
title: Optional[str]
version: str
summary: str
summary: SummaryStr
description: str
license: Optional[str]
type: Optional[str]
Expand All @@ -244,7 +244,9 @@ class SnapMetadata(SnapcraftMetadata):
plugs: Optional[Dict[str, Any]]
slots: Optional[Dict[str, Any]]
hooks: Optional[Dict[str, Any]]
layout: Optional[Dict[str, Dict[str, str]]]
layout: Optional[
Dict[str, Dict[Literal["symlink", "bind", "bind-file", "type"], str]]
]
system_usernames: Optional[Dict[str, Any]]
provenance: Optional[str]
links: Optional[Links]
Expand Down Expand Up @@ -448,8 +450,8 @@ def get_metadata_from_project(
name=project.name,
title=project.title,
version=version,
summary=project.summary,
description=project.description, # type: ignore
summary=cast(SummaryStr, project.summary),
description=cast(str, project.description),
license=project.license,
type=project.type,
architectures=[arch],
Expand Down
4 changes: 3 additions & 1 deletion tests/unit/services/test_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

from pathlib import Path

from craft_application.models import SummaryStr

from snapcraft import linters, meta, pack


Expand Down Expand Up @@ -49,7 +51,7 @@ def test_metadata(package_service, default_factory, new_dir):
name="default",
title=None,
version="1.0",
summary="default project",
summary=SummaryStr("default project"),
description="default project",
license="MIT",
type=None,
Expand Down

0 comments on commit 296079f

Please sign in to comment.