diff --git a/src/stac_asset/http_client.py b/src/stac_asset/http_client.py index 84c86cd..4599919 100644 --- a/src/stac_asset/http_client.py +++ b/src/stac_asset/http_client.py @@ -22,16 +22,6 @@ class HttpClient(Client): Configure the session to customize its behavior. """ - check_content_type: bool - """If true, check the asset's content type against the response from the server. - - See :py:func:`stac_asset.validate.content_type` for more information about - hte content type check. - """ - - session: ClientSession - """A atiohttp session that will be used for all requests.""" - @classmethod async def from_config(cls: Type[T], config: Config) -> T: """Creates the default http client with a vanilla session object.""" @@ -42,8 +32,16 @@ async def from_config(cls: Type[T], config: Config) -> T: def __init__(self, session: ClientSession, check_content_type: bool = True) -> None: super().__init__() - self.session = session - self.check_content_type = check_content_type + + self.session: ClientSession = session + """A aiohttp session that will be used for all requests.""" + + self.check_content_type: bool = check_content_type + """If true, check the asset's content type against the response from the server. + + See :py:func:`stac_asset.validate.content_type` for more information about + the content type check. + """ async def open_url( self, diff --git a/src/stac_asset/planetary_computer_client.py b/src/stac_asset/planetary_computer_client.py index ac59024..97b2c07 100644 --- a/src/stac_asset/planetary_computer_client.py +++ b/src/stac_asset/planetary_computer_client.py @@ -52,19 +52,17 @@ class PlanetaryComputerClient(HttpClient): thanks Tom Augspurger! """ - _cache: Dict[URL, _Token] - _cache_lock: Lock - token_request_url: URL - def __init__( self, session: ClientSession, sas_token_endpoint: str = DEFAULT_SAS_TOKEN_ENDPOINT, ) -> None: super().__init__(session) - self._cache = dict() - self._cache_lock = Lock() - self.sas_token_endpoint = URL(sas_token_endpoint) + self._cache: Dict[URL, _Token] = dict() + self._cache_lock: Lock = Lock() + + self.sas_token_endpoint: URL = URL(sas_token_endpoint) + """The endpoint that will be used to fetch a SAS token for reading.""" async def open_url( self, diff --git a/src/stac_asset/s3_client.py b/src/stac_asset/s3_client.py index fb76b83..b558927 100644 --- a/src/stac_asset/s3_client.py +++ b/src/stac_asset/s3_client.py @@ -30,27 +30,6 @@ class S3Client(Client): for instructions. """ - session: AioSession - """The session that will be used for all s3 requests.""" - - region_name: str - """The region that all clients will be rooted in.""" - - requester_pays: bool - """If True, enable access to `requester pays buckets - `_.""" - - retry_mode: str - """The retry mode, one of "adaptive", "legacy", or "standard". - - See `the boto3 docs - `_ - for more information on the available modes. - """ - - max_attempts: int - """The maximum number of attempts.""" - @classmethod async def from_config(cls, config: Config) -> S3Client: """Creates an s3 client from a config. @@ -76,11 +55,27 @@ def __init__( max_attempts: int = DEFAULT_S3_MAX_ATTEMPTS, ) -> None: super().__init__() - self.session = aiobotocore.session.get_session() - self.region_name = region_name - self.requester_pays = requester_pays - self.retry_mode = retry_mode - self.max_attempts = max_attempts + + self.session: AioSession = aiobotocore.session.get_session() + """The session that will be used for all s3 requests.""" + + self.region_name: str = region_name + """The region that all clients will be rooted in.""" + + self.requester_pays: bool = requester_pays + """If True, enable access to `requester pays buckets + `_.""" + + self.retry_mode: str = retry_mode + """The retry mode, one of "adaptive", "legacy", or "standard". + + See `the boto3 docs + `_ + for more information on the available modes. + """ + + self.max_attempts: int = max_attempts + """The maximum number of attempts.""" async def open_url( self,