Skip to content

Commit

Permalink
feat(stubs): validate RepoInfo source, add method for fetching contents.
Browse files Browse the repository at this point in the history
Signed-off-by: Braden Mars <bradenmars@bradenmars.me>
  • Loading branch information
BradenM committed Dec 11, 2022
1 parent afd2ba5 commit 0f7487f
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions micropy/stubs/repository_info.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
from __future__ import annotations

from pydantic import BaseModel
from datetime import timedelta
from typing import Any

import requests
from cachier import cachier
from pydantic import BaseModel, HttpUrl


class RepositoryInfo(BaseModel):
name: str
display_name: str
source: str
source: HttpUrl

class Config:
frozen = True

@cachier(stale_after=timedelta(days=1), next_time=True)
def fetch_source(self) -> dict[str, Any]:
return requests.get(self.source).json()

0 comments on commit 0f7487f

Please sign in to comment.