harbor run -t openthoughts/tasktrove-exp-flat25-stackoverflow-v2-5k-stackoverflow-2963harbor download openthoughts/tasktrove-exp-flat25-stackoverflow-v2-5k-stackoverflow-2963Title: Implement SearchLEI class in python_lei/lei_search.py with patchable _request_api; requirements and tests expect case-insensitive filtering by LegalName and NotFound on no results
Body: I’m building a small Python package that provides a searchable LEI lookup. I need to implement a module at python_lei/lei_search.py that exposes a class named SearchLEI with a private API helper and a public search method. The unit tests patch the internal API call, so the implementation must be designed to be easily mockable.
What to build
Public API
init(self, base_url: str = "<placeholder_api_endpoint>", timeout: float = 5.0)
search_lei(self, query: str) -> list[dict]
_request_api(self, query: str) -> list[dict]
Behavior considerations
Design notes
Acceptance criteria (mapped to tests)
Notes
Code skeleton (for reference; implement the full logic as described)
File: python_lei/lei_search.py
from typing import List, Dict
from python_lei.exceptions import NotFound
class SearchLEI:
def __init__(self, base_url: str = "<placeholder_api_endpoint>", timeout: float = 5.0):
self.base_url = base_url
self.timeout = timeout
def search_lei(self, query: str) -> List[Dict]:
# Implement: fetch, normalize, filter, raise NotFound if empty
pass
def _request_api(self, query: str) -> List[Dict]:
# Implement: HTTP GET to self.base_url with params {"q": query}
# Raise HTTPError on non-200
# Return JSON payload (list[dict])
pass
What I’m hoping for