launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #29729
[Merge] ~cjwatson/lpcraft:fix-mypy into lpcraft:main
Colin Watson has proposed merging ~cjwatson/lpcraft:fix-mypy into lpcraft:main.
Commit message:
Fix various mypy errors
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~cjwatson/lpcraft/+git/lpcraft/+merge/438534
--
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/lpcraft:fix-mypy into lpcraft:main.
diff --git a/NEWS.rst b/NEWS.rst
index 994ea0b..347d876 100644
--- a/NEWS.rst
+++ b/NEWS.rst
@@ -2,6 +2,11 @@
Version history
===============
+0.0.48 (unreleased)
+===================
+
+- Fix various ``mypy`` errors.
+
0.0.47 (2023-03-01)
===================
diff --git a/lpcraft/config.py b/lpcraft/config.py
index 4664176..8a3865c 100644
--- a/lpcraft/config.py
+++ b/lpcraft/config.py
@@ -47,13 +47,13 @@ class OutputDistributeEnum(Enum):
class Output(ModelConfigDefaults):
"""Job output properties."""
- paths: Optional[List[StrictStr]]
- distribute: Optional[OutputDistributeEnum]
- channels: Optional[List[StrictStr]]
+ paths: Optional[List[StrictStr]] = None
+ distribute: Optional[OutputDistributeEnum] = None
+ channels: Optional[List[StrictStr]] = None
# instead of `Any` this should be something like `JSONSerializable`
- properties: Optional[Dict[StrictStr, Any]]
- dynamic_properties: Optional[Path]
- expires: Optional[timedelta]
+ properties: Optional[Dict[StrictStr, Any]] = None
+ dynamic_properties: Optional[Path] = None
+ expires: Optional[timedelta] = None
@pydantic.validator("expires")
def validate_expires(cls, v: timedelta) -> timedelta:
@@ -151,12 +151,12 @@ class PackageRepository(ModelConfigDefaults):
"""
type: PackageType # e.g. `apt``
- ppa: Optional[PPAShortFormURL] # e.g. `launchpad/ubuntu/ppa`
- formats: Optional[List[PackageFormat]] # e.g. `[deb, deb-src]`
- components: Optional[List[PackageComponent]] # e.g. `[main, universe]`
- suites: Optional[List[PackageSuite]] # e.g. `[bionic, focal]`
- url: Optional[AnyHttpUrl]
- trusted: Optional[bool]
+ ppa: Optional[PPAShortFormURL] = None # e.g. `launchpad/ubuntu/ppa`
+ formats: Optional[List[PackageFormat]] = None # e.g. `[deb, deb-src]`
+ components: Optional[List[PackageComponent]] = None # e.g. `[main]`
+ suites: Optional[List[PackageSuite]] = None # e.g. `[bionic, focal]`
+ url: Optional[AnyHttpUrl] = None
+ trusted: Optional[bool] = False
@root_validator(pre=True)
def validate_multiple_fields(
diff --git a/lpcraft/plugins/plugins.py b/lpcraft/plugins/plugins.py
index d4464ee..4dbad96 100644
--- a/lpcraft/plugins/plugins.py
+++ b/lpcraft/plugins/plugins.py
@@ -30,7 +30,7 @@ if TYPE_CHECKING:
class BaseConfig(
pydantic.BaseModel,
extra=pydantic.Extra.forbid,
- frozen=True,
+ allow_mutation=False,
alias_generator=lambda s: s.replace("_", "-"),
underscore_attrs_are_private=True,
):
diff --git a/lpcraft/tests/test_config.py b/lpcraft/tests/test_config.py
index 58248e8..d64533a 100644
--- a/lpcraft/tests/test_config.py
+++ b/lpcraft/tests/test_config.py
@@ -20,7 +20,11 @@ from lpcraft.config import (
LAUNCHPAD_PPA_BASE_URL,
Config,
OutputDistributeEnum,
+ PackageComponent,
+ PackageFormat,
PackageRepository,
+ PackageSuite,
+ PackageType,
PPAShortFormURL,
get_ppa_url_parts,
)
@@ -479,10 +483,10 @@ class TestConfig(TestCase):
self.assertEqual(
[
PackageRepository(
- type="apt",
- formats=["deb"],
- components=["main"],
- suites=["focal"],
+ type=PackageType.apt,
+ formats=[PackageFormat.deb],
+ components=[PackageComponent.main],
+ suites=[PackageSuite.focal],
url=AnyHttpUrl(
"https://canonical.example.org/artifactory/jammy-golang-backport", # noqa: E501
scheme="https",
@@ -493,10 +497,10 @@ class TestConfig(TestCase):
),
),
PackageRepository(
- type="apt",
- formats=["deb"],
- components=["main"],
- suites=["focal"],
+ type=PackageType.apt,
+ formats=[PackageFormat.deb],
+ components=[PackageComponent.main],
+ suites=[PackageSuite.focal],
url=AnyHttpUrl(
"https://canonical.example.org/artifactory/jammy-golang-backport", # noqa: E501
scheme="https",
diff --git a/setup.cfg b/setup.cfg
index ed2d392..c9f86c9 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -1,6 +1,6 @@
[metadata]
name = lpcraft
-version = 0.0.47
+version = 0.0.48.dev0
description = Runner for Launchpad CI jobs
long_description = file: README.rst
long_description_content_type = text/x-rst