Skip to content

Commit f03ca33

Browse files
Lev RubelЛев
Lev Rubel
and
Лев
authored
Fixed serializers base class bug, revealed after latest pydantic vers… (#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>
1 parent 0816706 commit f03ca33

File tree

12 files changed

+32
-22
lines changed

12 files changed

+32
-22
lines changed

.github/workflows/pythonpackage.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
strategy:
1010
max-parallel: 4
1111
matrix:
12-
python-version: [3.6, 3.7, 3.8]
12+
python-version: [3.7, 3.8, 3.9]
1313

1414
steps:
1515
- uses: actions/checkout@v1

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
language: python
22
python:
3+
- 3.9
34
- 3.8
45
- 3.7
5-
- 3.6
66
install: pip install -U tox-travis
77
script: tox
88
deploy:

CONTRIBUTING.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ Before you submit a pull request, check that it meets these guidelines:
102102
2. If the pull request adds functionality, the docs should be updated. Put
103103
your new functionality into a function with a docstring, and add the
104104
feature to the list in README.rst.
105-
3. The pull request should work for Python 3.6, 3.7, 3.8. Check
105+
3. The pull request should work for Python 3.7, 3.8, 3.9. Check
106106
https://travis-ci.org/identixone/fastapi_contrib/pull_requests
107107
and make sure that the tests pass for all supported Python versions.
108108

fastapi_contrib/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44

55
__author__ = """Lev Rubel"""
66
__email__ = 'l@datacorp.ee'
7-
__version__ = '0.2.9'
7+
__version__ = '0.2.10'

fastapi_contrib/conf.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
1+
import os
2+
from pathlib import Path
3+
14
from pydantic import BaseSettings
2-
from typing import List
5+
from typing import List, Optional
6+
7+
contrib_secrets_dir: Optional[str] = os.environ.get(
8+
"CONTRIB_SECRETS_DIR", "/run/secrets"
9+
)
10+
if not Path(contrib_secrets_dir).exists():
11+
contrib_secrets_dir = None
312

413

514
class Settings(BaseSettings):
@@ -67,6 +76,7 @@ class Settings(BaseSettings):
6776

6877
class Config:
6978
env_prefix = "CONTRIB_"
79+
secrets_dir = contrib_secrets_dir
7080

7181

7282
# TODO: ability to override this settings class from the actual app

fastapi_contrib/serializers/common.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ async def save(
119119
hasattr(self, "Meta")
120120
and getattr(self.Meta, "model", None) is not None
121121
):
122-
instance = self.Meta.model(**self.__values__)
122+
instance = self.Meta.model(**self.__dict__)
123123
await instance.save(
124124
include=include, exclude=exclude, rewrite_fields=rewrite_fields
125125
)

requirements_dev.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ Sphinx>=2.4.3
66
twine>=3.1.1
77

88
contextvars==2.4;python_version<"3.7"
9-
fastapi>=0.52.0
10-
pydantic>=1.4
9+
fastapi>=0.63.0
1110
jaeger-client>=4.1.0
1211
opentracing>=2.2.0
1312
motor>=2.0.0

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[bumpversion]
2-
current_version = 0.2.9
2+
current_version = 0.2.10
33
commit = True
44
tag = True
55

setup.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@
99
readme = readme_file.read()
1010

1111
requirements = [
12-
'fastapi>=0.52.0',
13-
'pydantic>=1.4',
14-
'contextvars;python_version<"3.7"'
12+
'fastapi>=0.63.0'
1513
]
1614

1715
setup_requirements = ["pytest-runner"]
@@ -27,9 +25,9 @@
2725
"License :: OSI Approved :: MIT License",
2826
"Natural Language :: English",
2927
"Programming Language :: Python :: 3",
30-
"Programming Language :: Python :: 3.6",
3128
"Programming Language :: Python :: 3.7",
3229
"Programming Language :: Python :: 3.8",
30+
"Programming Language :: Python :: 3.9",
3331
],
3432
description="Opinionated set of utilities on top of FastAPI",
3533
install_requires=requirements,
@@ -56,6 +54,6 @@
5654
test_suite="tests",
5755
tests_require=test_requirements,
5856
url="https://github.com/identixone/fastapi_contrib",
59-
version="0.2.9",
57+
version="0.2.10",
6058
zip_safe=False,
6159
)

tests/conftest.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
11
import os
2+
from pathlib import Path
23

4+
p = Path("/tmp/secrets")
5+
p.mkdir(parents=True, exist_ok=True)
6+
with open("/tmp/secrets/contrib_jaeger_sampler_rate", "w") as f:
7+
f.write("0.1")
8+
os.environ["CONTRIB_SECRETS_DIR"] = "/tmp/secrets"
39
os.environ["CONTRIB_FASTAPI_APP"] = "tests.conftest.app"

tests/test_conf.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
#!/usr/bin/env python
2-
# -*- coding: utf-8 -*-
3-
4-
from fastapi_contrib.conf import settings
5-
6-
71
def test_settings_from_env_and_defaults():
2+
from fastapi_contrib.conf import settings
83
assert settings.fastapi_app == "tests.conftest.app"
94
assert settings.now_function is None
5+
assert settings.Config.secrets_dir == "/tmp/secrets"
6+
assert settings.jaeger_sampler_rate == 0.1

tox.ini

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
[tox]
2-
envlist = py36, py37, py38, flake8
2+
envlist = py37, py38, py39, flake8
33

44
[travis]
55
python =
6-
3.6: py36
76
3.7: py37
87
3.8: py38
8+
3.9: py39
99

1010
[testenv:flake8]
1111
basepython = python

0 commit comments

Comments
 (0)