Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: CI

on:
push:
branches: [main, master]
pull_request:
branches: [main, master]

jobs:
test:
name: Test (Python ${{ matrix.python-version }})
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.8, 3.9, "3.10", 3.11, 3.12]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install tox
run: python -m pip install --upgrade pip tox
- name: Run tox
run: tox -e py${{ matrix.python-version }}
- name: Upload coverage to Codecov
if: always() # Always run even if tests fail
uses: codecov/codecov-action@v4
with:
files: coverage.xml
fail_ci_if_error: false
15 changes: 15 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
version: 2

# Set the OS, Python version and other tools you might need
build:
os: ubuntu-22.04
tools:
python: "3.12"

# Build documentation in the "docs/" directory with Sphinx
sphinx:
configuration: docs/conf.py

python:
install:
- requirements: dev-requirements.txt
9 changes: 3 additions & 6 deletions aumbry/contract.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import abc
import os
import importlib
import six

from alchemize.mapping import JsonMappedModel
from aumbry.errors import DependencyError
Expand All @@ -24,15 +23,14 @@ def _import(req, pkg=None):
raise DependencyError(self.extras_name)

for req in self.imports:
if isinstance(req, six.text_type) or isinstance(req, str):
if isinstance(req, str):
_import(req)
else:
name, package = req
_import(name, package)


@six.add_metaclass(abc.ABCMeta)
class AbstractSource(PluginBase):
class AbstractSource(PluginBase, metaclass=abc.ABCMeta):
def __init__(self, options=None):
self.options = options or {}

Expand Down Expand Up @@ -62,8 +60,7 @@ def environmental_vars(self):
return {key: os.environ[key] for key in keys_to_fetch}


@six.add_metaclass(abc.ABCMeta)
class AbstractHandler(PluginBase):
class AbstractHandler(PluginBase, metaclass=abc.ABCMeta):
@abc.abstractmethod
def deserialize(self, raw_config, config_cls):
""" Method to handle deserialization to a Config object. """
Expand Down
2 changes: 1 addition & 1 deletion aumbry/sources/consul.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import time
import base64
from six.moves.urllib.parse import urljoin
from urllib.parse import urljoin

from aumbry.contract import AbstractSource
from aumbry.errors import LoadError
Expand Down
2 changes: 1 addition & 1 deletion aumbry/sources/etcd2.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import base64
import time
from six.moves.urllib.parse import urljoin
from urllib.parse import urljoin

from aumbry.contract import AbstractSource
from aumbry.errors import LoadError, SaveError
Expand Down
646 changes: 646 additions & 0 deletions poetry.lock

Large diffs are not rendered by default.

50 changes: 50 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
[tool.poetry]
name = "aumbry"
version = "0.10.0"
description = "Multi-type configuration library for Python"
authors = ["John Vrbanac <john.vrbanac@linux.com>"]
license = "Apache v2"
readme = "README.rst"
homepage = "https://github.com/pyarmory/aumbry"
keywords = ["configuration", "yaml", "etcd", "json", "parameter", "store", "multiple"]
classifiers = [
"Development Status :: 3 - Alpha",
"Intended Audience :: Developers",
"License :: OSI Approved :: Apache Software License",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3.4",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: Implementation :: PyPy",
]

[tool.poetry.dependencies]
python = ">=3.7"
alchemize = ">=0.10.0"
pike = "*"
deepmerge = "*"
pyyaml = { version = ">=5.1", optional = true }
cryptography = { version = ">=2.1.2", optional = true }

[tool.poetry.extras]
yaml = ["pyyaml"]
consul = ["requests"]
etcd2 = ["requests"]
param_store = ["boto3"]
fernet = ["cryptography"]
cli = ["pyyaml", "requests", "boto3", "cryptography"]

[tool.poetry.scripts]
aumbry = "aumbry.cli.app:main"

[tool.poetry.group.dev.dependencies]
flake8 = "<5.0.4"
specter = "^0.6.1"
requests-mock = "^1.12.1"
pretend = "^1.0.9"

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
57 changes: 0 additions & 57 deletions setup.py

This file was deleted.

6 changes: 3 additions & 3 deletions spec/cli/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def can_upload(self):

assert SampleConfig.__name__ == args[1].__name__
assert 'CONFIG_FILE_PATH' in args[2]
assert type(kwargs['handler']) == YamlHandler
assert type(kwargs['handler']) is YamlHandler

def file_type_defaults_to_json(self):
with OutputCapture():
Expand All @@ -61,7 +61,7 @@ def file_type_defaults_to_json(self):

assert SampleConfig.__name__ == args[1].__name__
assert 'CONFIG_FILE_PATH' in args[2]
assert type(kwargs['handler']) == JsonHandler
assert type(kwargs['handler']) is JsonHandler

def output_handler_defaults_to_none(self):
with OutputCapture():
Expand All @@ -81,7 +81,7 @@ def output_handler_defaults_to_none(self):

assert SampleConfig.__name__ == args[1].__name__
assert 'CONFIG_FILE_PATH' in args[2]
assert type(kwargs['handler']) == JsonHandler
assert type(kwargs['handler']) is JsonHandler

args, kwargs = self.save_mock.call_args
assert kwargs['handler'] is None
Expand Down
3 changes: 2 additions & 1 deletion spec/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
import os
import tempfile
from textwrap import dedent
import urllib.parse

from cryptography.fernet import Fernet
import requests_mock
from specter import Spec, DataSpec, expect
from six.moves import urllib

from moto import mock_ssm
from pike.discovery import py

Expand Down
6 changes: 3 additions & 3 deletions spec/utils/__init__.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import six
import io
import sys


class OutputCapture(list):
def __enter__(self):
self._stdout = sys.stdout
self._stderr = sys.stderr
sys.stdout = self._stdoutio = six.StringIO()
sys.stderr = self._stderrio = six.StringIO()
sys.stdout = self._stdoutio = io.StringIO()
sys.stderr = self._stderrio = io.StringIO()

return self

Expand Down
4 changes: 2 additions & 2 deletions spec/utils/file.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import builtins
import os
import mock
import six
import tempfile

from specter import Spec, expect
Expand Down Expand Up @@ -34,7 +34,7 @@ def magic_open(fn, mode):
open_mock.side_effect = magic_open
raised_error = False

patch_name = '{}.open'.format(six.moves.builtins.__name__)
patch_name = '{}.open'.format(builtins.__name__)
with mock.patch(patch_name, open_mock):
# Doing this manually as test suites use open()
try:
Expand Down
4 changes: 2 additions & 2 deletions test-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
flake8
mock
requests-mock
specter>=0.6.1
moto>=1.0.1
specter>=0.7.0
moto>=1.0.1,<=4.2.14
pretend
6 changes: 5 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist = flake8, py27, py34, py35, py36, py37, py38 pypy
envlist = flake8, py3.7, py3.8, py3.9, py3.10, py3.11, py3.12

[testenv]
setenv =
Expand All @@ -12,7 +12,11 @@ deps =
commands =
coverage run -m specter
coverage report -m
coverage xml

[testenv:flake8]
ignore = H301,H405,H702,W503,W504,E722
basepython = python3.8
commands =
flake8 --statistics -j auto --count aumbry spec