-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP: Add typing to configstore #28
Changes from 4 commits
b6eeecf
7041518
3988b89
9945746
6307d64
06efe00
b92c96a
441cb85
4b9007c
123f2b1
252f455
7019745
c7d465a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
__pycache__ | ||
|
||
# Test artifacts | ||
/.mypy_cache/ | ||
/.pytest_cache/ | ||
/.coverage | ||
/.tox/ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,15 @@ | ||
from typing import TypeVar | ||
|
||
from .backends.env_var import EnvVarBackend | ||
from .backends.dotenv import DotenvBackend | ||
from .backends.awsssm import AwsSsmBackend | ||
from .backends.docker_secret import DockerSecretBackend | ||
|
||
|
||
Backends = TypeVar('Backends', EnvVarBackend, DotenvBackend, | ||
AwsSsmBackend, DockerSecretBackend) | ||
|
||
|
||
class SettingNotFoundException(Exception): | ||
pass | ||
|
||
|
@@ -7,13 +19,13 @@ class SettingNotFoundException(Exception): | |
|
||
class Store(object): | ||
|
||
def __init__(self, backends): | ||
def __init__(self, backends) -> None: | ||
self._backends = tuple(backends) | ||
|
||
def add_backend(self, backend): | ||
def add_backend(self, backend: Backends): | ||
self._backends += (backend,) | ||
|
||
def get_setting(self, key, default=_no_default): | ||
def get_setting(self, key: str, default=_no_default) -> str: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ici, default devrait être un string. Sauf que si default peut être J'aurais tendance à faire un _no_default avec une valeur en string, mais faut trouver un default qui ne se retrouverait pas dans un default. Tu en pense quoi @merwok ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
for backend in self._backends: | ||
ret = backend.get_setting(key) | ||
if ret is None: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It’s not great to have to import all backends here.
Could we declare and interface or ABC or base type and use that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I woudl really prefer to declare a base class or an interface. It was my first plan, but I wasn't sure if you'd like it and I saw the TypeVar in the documentation.
My toher questions is since we'll have a backend inteface. could we move all backend in a
backends.py
file with theBackend
class ?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Go for an ABC or whatever is recommended by typing / mypy.
I don’t see benefits in moving the concrete backend classes though.