Skip to content

Commit

Permalink
Optional type hints accidentally deleted
Browse files Browse the repository at this point in the history
Problem:
The optional type hints were accidentally deleted.

Solution:
Added type hints back and added comments in code to keep things in sync.

Signed-off-by: Paul Hewlett <phewlett76@gmail.com>
  • Loading branch information
eccles committed Jun 28, 2021
1 parent 0395064 commit 079928e
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions archivist/archivist.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@

import json
from os.path import isfile as os_path_isfile
from typing import Optional

from flatten_dict import flatten
import requests
Expand Down Expand Up @@ -61,6 +62,7 @@

LOGGER = logging.getLogger(__name__)

# also change the type hints in __init__ below
CLIENTS = {
"assets": _AssetsClient,
"events": _EventsClient,
Expand Down Expand Up @@ -111,6 +113,14 @@ def __init__(self, url, *, auth=None, cert=None, verify=True):

self._cert = cert

# keep these in sync with CLIENTS map above
self.assets: Optional[_AssetsClient]
self.events: Optional[_EventsClient]
self.locations: Optional[_LocationsClient]
self.attachments: Optional[_AttachmentsClient]
self.access_policies: Optional[_AccessPoliciesClient]
self.subjects: Optional[_SubjectsClient]

def __getattr__(self, value):
"""Create endpoints on demand"""
client = CLIENTS.get(value)
Expand Down

0 comments on commit 079928e

Please sign in to comment.