From b5a98204becae929657b6ca65d5ceded3f6e084f Mon Sep 17 00:00:00 2001 From: Simo Tumelius Date: Thu, 14 Jul 2022 10:54:33 +0300 Subject: [PATCH] Fix compatibility with Python3.6 and Python3.7 (#60) * Fix ClickBaseModel.click_options is now compatible with Python3.6 and Python3.7 * Update README * Add tox configuration Co-authored-by: Simo Tumelius --- .gitignore | 5 ++++- README.md | 8 +++++++- dbt_cloud/command/command.py | 3 ++- pyproject.toml | 2 +- tox.ini | 9 +++++++++ 5 files changed, 23 insertions(+), 4 deletions(-) create mode 100644 tox.ini diff --git a/.gitignore b/.gitignore index f7e107f..489f58a 100644 --- a/.gitignore +++ b/.gitignore @@ -10,4 +10,7 @@ dist/ # pytest-cov .coverage -cov_html/ \ No newline at end of file +cov_html/ + +# tox +.tox/ \ No newline at end of file diff --git a/README.md b/README.md index 0cdc71f..fd9d6b9 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,13 @@ ## Installation -`dbt-cloud-cli` has been tested on Python 3.8 but it should work on Python>=3.6. +`dbt-cloud-cli` has been tested with the following Python versions: + +* ✅ Python 3.6 +* ✅ Python 3.7 +* ✅ Python 3.8 +* ✅ Python 3.9 +* ✅ Python 3.10 Installation from PyPI: diff --git a/dbt_cloud/command/command.py b/dbt_cloud/command/command.py index b800bf4..24858e6 100644 --- a/dbt_cloud/command/command.py +++ b/dbt_cloud/command/command.py @@ -1,4 +1,5 @@ import click +from collections import OrderedDict from mergedeep import merge from pydantic import validator, BaseModel, PrivateAttr from dbt_cloud.serde import json_to_dict @@ -21,7 +22,7 @@ def translate_click_options(**kwargs) -> dict: class ClickBaseModel(BaseModel): @classmethod def click_options(cls, function, key_prefix: str = ""): - for key, field in reversed(cls.__fields__.items()): + for key, field in reversed(OrderedDict(cls.__fields__).items()): try: is_nested_object = issubclass(field.type_, BaseModel) except TypeError: diff --git a/pyproject.toml b/pyproject.toml index 200b6e4..e281bdd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,4 +1,4 @@ [tool.black] skip-string-normalization = false include = '\.pyi?$' -exclude = 'venv/' \ No newline at end of file +exclude = 'venv/|.tox/' \ No newline at end of file diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..85d2f33 --- /dev/null +++ b/tox.ini @@ -0,0 +1,9 @@ +[tox] +envlist = py36, py37, py38, py39, p310 +[testenv] +commands = + pytest +setenv = + DBT_CLOUD_ACCOUNT_ID = 123456 +deps = + -e .[test] \ No newline at end of file