-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(stubs): add Micropython stubs package/manifest models.
- Loading branch information
Showing
2 changed files
with
35 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
from . import micropy, micropython | ||
from .micropy import MicropyStubPackage, MicropyStubsManifest | ||
from .micropython import MicropythonStubsManifest, MicropythonStubsPackage | ||
|
||
__all__ = [ | ||
"MicropyStubsManifest", | ||
"MicropyStubPackage", | ||
"MicropythonStubsPackage", | ||
"MicropythonStubsManifest", | ||
] |
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,25 @@ | ||
from __future__ import annotations | ||
|
||
from pydantic import Field, validator | ||
from typing_extensions import Annotated | ||
|
||
from ..manifest import StubsManifest | ||
from ..package import StubPackage | ||
|
||
|
||
class MicropythonStubsPackage(StubPackage): | ||
name: str | ||
version: Annotated[str, Field(alias="pkg_version")] | ||
|
||
@property | ||
def package_name(self) -> str: | ||
return f"{self.name}@{self.version}" | ||
|
||
|
||
class MicropythonStubsManifest(StubsManifest): | ||
packages: list[MicropythonStubsPackage] | ||
|
||
@validator("packages", pre=True) | ||
def _get_packages(cls, v: dict[str, dict]): | ||
data = v["data"].values() | ||
return list(data) |