Skip to content

Commit

Permalink
Fixed serializers base class bug, revealed after latest pydantic vers… (
Browse files Browse the repository at this point in the history
#168)

* Fixed serializers base class bug, revealed after latest pydantic version update; Updated version of this package; Added support for secrets file in configuration

* Removed Support for Python 3.6, Added Support for Python 3.9

Co-authored-by: Лев <lev@awesome-host.local>
  • Loading branch information
Lev Rubel and Лев committed Mar 1, 2021
1 parent 0816706 commit f03ca33
Show file tree
Hide file tree
Showing 12 changed files with 32 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pythonpackage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
strategy:
max-parallel: 4
matrix:
python-version: [3.6, 3.7, 3.8]
python-version: [3.7, 3.8, 3.9]

steps:
- uses: actions/checkout@v1
Expand Down
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
language: python
python:
- 3.9
- 3.8
- 3.7
- 3.6
install: pip install -U tox-travis
script: tox
deploy:
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ Before you submit a pull request, check that it meets these guidelines:
2. If the pull request adds functionality, the docs should be updated. Put
your new functionality into a function with a docstring, and add the
feature to the list in README.rst.
3. The pull request should work for Python 3.6, 3.7, 3.8. Check
3. The pull request should work for Python 3.7, 3.8, 3.9. Check
https://travis-ci.org/identixone/fastapi_contrib/pull_requests
and make sure that the tests pass for all supported Python versions.

Expand Down
2 changes: 1 addition & 1 deletion fastapi_contrib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@

__author__ = """Lev Rubel"""
__email__ = 'l@datacorp.ee'
__version__ = '0.2.9'
__version__ = '0.2.10'
12 changes: 11 additions & 1 deletion fastapi_contrib/conf.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
import os
from pathlib import Path

from pydantic import BaseSettings
from typing import List
from typing import List, Optional

contrib_secrets_dir: Optional[str] = os.environ.get(
"CONTRIB_SECRETS_DIR", "/run/secrets"
)
if not Path(contrib_secrets_dir).exists():
contrib_secrets_dir = None


class Settings(BaseSettings):
Expand Down Expand Up @@ -67,6 +76,7 @@ class Settings(BaseSettings):

class Config:
env_prefix = "CONTRIB_"
secrets_dir = contrib_secrets_dir


# TODO: ability to override this settings class from the actual app
Expand Down
2 changes: 1 addition & 1 deletion fastapi_contrib/serializers/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ async def save(
hasattr(self, "Meta")
and getattr(self.Meta, "model", None) is not None
):
instance = self.Meta.model(**self.__values__)
instance = self.Meta.model(**self.__dict__)
await instance.save(
include=include, exclude=exclude, rewrite_fields=rewrite_fields
)
Expand Down
3 changes: 1 addition & 2 deletions requirements_dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ Sphinx>=2.4.3
twine>=3.1.1

contextvars==2.4;python_version<"3.7"
fastapi>=0.52.0
pydantic>=1.4
fastapi>=0.63.0
jaeger-client>=4.1.0
opentracing>=2.2.0
motor>=2.0.0
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.2.9
current_version = 0.2.10
commit = True
tag = True

Expand Down
8 changes: 3 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@
readme = readme_file.read()

requirements = [
'fastapi>=0.52.0',
'pydantic>=1.4',
'contextvars;python_version<"3.7"'
'fastapi>=0.63.0'
]

setup_requirements = ["pytest-runner"]
Expand All @@ -27,9 +25,9 @@
"License :: OSI Approved :: MIT License",
"Natural Language :: English",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
],
description="Opinionated set of utilities on top of FastAPI",
install_requires=requirements,
Expand All @@ -56,6 +54,6 @@
test_suite="tests",
tests_require=test_requirements,
url="https://github.com/identixone/fastapi_contrib",
version="0.2.9",
version="0.2.10",
zip_safe=False,
)
6 changes: 6 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
import os
from pathlib import Path

p = Path("/tmp/secrets")
p.mkdir(parents=True, exist_ok=True)
with open("/tmp/secrets/contrib_jaeger_sampler_rate", "w") as f:
f.write("0.1")
os.environ["CONTRIB_SECRETS_DIR"] = "/tmp/secrets"
os.environ["CONTRIB_FASTAPI_APP"] = "tests.conftest.app"
9 changes: 3 additions & 6 deletions tests/test_conf.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from fastapi_contrib.conf import settings


def test_settings_from_env_and_defaults():
from fastapi_contrib.conf import settings
assert settings.fastapi_app == "tests.conftest.app"
assert settings.now_function is None
assert settings.Config.secrets_dir == "/tmp/secrets"
assert settings.jaeger_sampler_rate == 0.1
4 changes: 2 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[tox]
envlist = py36, py37, py38, flake8
envlist = py37, py38, py39, flake8

[travis]
python =
3.6: py36
3.7: py37
3.8: py38
3.9: py39

[testenv:flake8]
basepython = python
Expand Down

0 comments on commit f03ca33

Please sign in to comment.