Skip to content

Commit

Permalink
feat(stubs): impl resolve package method in StubRepository.
Browse files Browse the repository at this point in the history
  • Loading branch information
BradenM committed Dec 11, 2022
1 parent 4fd1b12 commit c28d988
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions micropy/stubs/repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from typing import TYPE_CHECKING, Generator

import attrs
import micropy.exceptions as exc
import requests

from .manifest import StubsManifest
Expand Down Expand Up @@ -63,3 +64,9 @@ def search(self, query: str) -> Generator[StubRepositoryPackage, None, None]:
for package in self.packages:
if query in package.package.name.lower():
yield package

def resolve_package(self, name: str) -> str:
pkg = next((p for p in self.packages if p.package.name == name), None)
if pkg is None:
raise exc.StubNotFound(pkg)
return pkg.url

0 comments on commit c28d988

Please sign in to comment.