Skip to content

Commit

Permalink
feat(stubs): add Micropython stubs package/manifest models.
Browse files Browse the repository at this point in the history
  • Loading branch information
BradenM committed Dec 11, 2022
1 parent 021c279 commit a9297dc
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
10 changes: 10 additions & 0 deletions micropy/stubs/repositories/__init__.py
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",
]
25 changes: 25 additions & 0 deletions micropy/stubs/repositories/micropython.py
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)

0 comments on commit a9297dc

Please sign in to comment.