-
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 12 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 |
---|---|---|
|
@@ -4,10 +4,8 @@ workflows: | |
version: 2 | ||
configstore: | ||
jobs: | ||
- test-py35 | ||
- test-py36 | ||
- test-py37 | ||
- test-py27 | ||
- check | ||
|
||
jobs: | ||
|
@@ -63,57 +61,6 @@ jobs: | |
- store_test_results: | ||
path: ~/reports | ||
|
||
test-py35: | ||
docker: | ||
- image: circleci/python:3.5 | ||
working_directory: ~/configstore | ||
steps: | ||
- checkout | ||
- restore_cache: | ||
key: configstore-py35-v2 | ||
- run: | ||
name: Install CI tools | ||
command: | | ||
python3.5 -m venv venv | ||
venv/bin/pip install tox | ||
- run: | ||
name: Test with Python 3.5 | ||
command: venv/bin/tox -e py35 -- --junitxml=~/reports/tox/coverage.xml | ||
- save_cache: | ||
key: configstore-py35-v2 | ||
paths: | ||
- venv | ||
- .tox | ||
- store_test_results: | ||
path: ~/reports | ||
|
||
test-py27: | ||
docker: | ||
# This image contains Python 3.6 (to install flit) and 2.7 (to run tests) | ||
- image: circleci/python:3.6 | ||
working_directory: ~/configstore | ||
steps: | ||
- checkout | ||
- restore_cache: | ||
key: configstore-py27-v2 | ||
- run: | ||
name: Install CI tools | ||
command: | | ||
python3.6 -m venv venv | ||
venv/bin/pip install tox | ||
- run: | ||
name: Test with Python 2.7 | ||
command: | | ||
venv/bin/tox --sdistonly | ||
venv/bin/tox -e py27 -- --junitxml=~/reports/tox/coverage.xml | ||
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. There’s some config that can be removed from tox.ini too if you want to clean up. |
||
- save_cache: | ||
key: configstore-py27-v2 | ||
paths: | ||
- venv | ||
- .tox | ||
- store_test_results: | ||
path: ~/reports | ||
|
||
check: | ||
docker: | ||
- image: circleci/python:3.7 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,8 @@ __pycache__ | |
/.coverage | ||
/.tox/ | ||
/venv/ | ||
/.pyre/ | ||
.pyre_configuration | ||
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. Does this file live at the repo root? 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. Normally yes. |
||
|
||
# Packaging litter | ||
/configstore.egg-info | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
from .awsssm import AwsSsmBackend | ||
from .base import Backend | ||
from .docker_secret import DockerSecretBackend | ||
from .dotenv import DotenvBackend | ||
from .env_var import EnvVarBackend | ||
|
||
__all__ = [ | ||
'EnvVarBackend', 'DotenvBackend', 'DockerSecretBackend', 'AwsSsmBackend', | ||
'Backend', 'EnvVarBackend', 'DotenvBackend', 'DockerSecretBackend', 'AwsSsmBackend', | ||
] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
from typing import Optional | ||
|
||
|
||
class Backend(object): | ||
|
||
def __init__(self) -> None: | ||
pass | ||
|
||
def get_setting(self, key: str) -> Optional[str]: | ||
raise NotImplementedError | ||
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. I would like this to be a real abstract base class, and also keep the duck typing (not require that classes inherit from the base class). We could chat about this on Monday, the background and reasoning could be quite long for a review message! (Duck typing / virtual subclasses can be handled by typing: https://mypy.readthedocs.io/en/stable/protocols.html#protocol-types ) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,11 @@ | ||
import os | ||
|
||
from .base import Backend | ||
|
||
class EnvVarBackend(object): | ||
from typing import Optional | ||
|
||
def get_setting(self, config): | ||
return os.environ.get(config) | ||
|
||
class EnvVarBackend(Backend): | ||
|
||
def get_setting(self, key: str) -> Optional[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. Great job fixing the param names in get_setting methods! |
||
return os.environ.get(key) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import pytest | ||
|
||
from configstore.backends.base import Backend | ||
|
||
|
||
def test_backend_get_setting_is_not_implemented(): | ||
backend = Backend() | ||
|
||
with pytest.raises(NotImplementedError): | ||
backend.get_setting('test') |
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.
Comme python 3.5 est juste en security status et que certaine type hint ne sont pas supporté dedans, mais le sont dans python 3.6 et 3.7, j'ai enlevé le support de 3.5.