Coverage for src/usaspending/resources/base_resource.py: 100%

11 statements  

« prev     ^ index     » next       coverage.py v7.10.6, created at 2025-09-03 17:15 -0700

1from __future__ import annotations 

2from typing import TYPE_CHECKING 

3 

4from ..logging_config import USASpendingLogger 

5 

6if TYPE_CHECKING: 

7 from ..client import USASpending 

8 

9logger = USASpendingLogger.get_logger(__name__) 

10 

11 

12class BaseResource: 

13 """Base class for API resources. 

14 

15 Resources provide structured gateways to USASpending API endpoints 

16 and return appropriate query builders or model instances. 

17 """ 

18 

19 def __init__(self, client: USASpending): 

20 """Initialize resource with client reference. 

21 

22 Args: 

23 client: USASpending client instance 

24 """ 

25 self._client: USASpending = client 

26 logger.debug(f"Initialized {self.__class__.__name__} resource") 

27 

28 @property 

29 def client(self) -> USASpending: 

30 """Get client instance.""" 

31 return self._client