From c3c873b9d5902856d1b41e26831e2953e4128eeb Mon Sep 17 00:00:00 2001 From: Jim Fawkes Date: Thu, 22 Dec 2022 14:55:16 +0100 Subject: [PATCH 1/5] Upgrade dependencies --- requirements/base.txt | 5 ++--- requirements/local.txt | 13 ++++++------- requirements/test.txt | 4 ++-- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/requirements/base.txt b/requirements/base.txt index cdbd856..36de843 100644 --- a/requirements/base.txt +++ b/requirements/base.txt @@ -1,3 +1,2 @@ -boto3==1.13.16 -botocore==1.16.16 -python-dotenv==0.13.0 +boto3<1.27,>1.13 +python-dotenv<0.22,>0.13 diff --git a/requirements/local.txt b/requirements/local.txt index 762f170..70abfb2 100644 --- a/requirements/local.txt +++ b/requirements/local.txt @@ -2,10 +2,9 @@ # Inherit from test and base -r test.txt -black==19.10b0 -bandit==1.6.2 -mypy==0.761 -pre-commit==1.20.0 -pyflakes==2.1.1 -pylama==7.7.1 - +black==22.12 +bandit==1.7.4 +mypy==0.991 +pre-commit==2.20.0 +pyflakes==3.0.1 +pylama==8.4.1 diff --git a/requirements/test.txt b/requirements/test.txt index 8af433a..2713c49 100644 --- a/requirements/test.txt +++ b/requirements/test.txt @@ -1,5 +1,5 @@ # Requirements to run tests (Local or CI) -r base.txt -pytest==5.4.2 -tox==3.14.5 +pytest==7.2.0 +tox==4.0.16 From ef2c47bebce824a51eb34496a9aa06f272540b67 Mon Sep 17 00:00:00 2001 From: Jim Fawkes Date: Thu, 22 Dec 2022 15:39:41 +0100 Subject: [PATCH 2/5] Re-organize Requirements --- .github/workflows/ci.yml | 23 ++++------------------- pyproject.toml | 14 +++++++------- requirements-dev.txt | 17 +++++++++++++++++ requirements/base.txt | 2 -- requirements/local.txt | 10 ---------- requirements/prod.txt | 2 -- requirements/test.txt | 5 ----- 7 files changed, 28 insertions(+), 45 deletions(-) create mode 100644 requirements-dev.txt delete mode 100644 requirements/base.txt delete mode 100644 requirements/local.txt delete mode 100644 requirements/prod.txt delete mode 100644 requirements/test.txt diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4e1122c..9e2930d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,29 +20,14 @@ jobs: run: | python --version python -m pip install --upgrade pip - pip install -r requirements/test.txt + pip install -r requirements-dev.txt + - name: Test with pytest run: | - pip install pytest - pip install pytest-cov pytest --cov=./ --cov-report=xml + - name: Codecov - uses: codecov/codecov-action@v1.0.5 + uses: codecov/codecov-action@v3.1.1 with: token: ${{ secrets.CODECOV_TOKEN }} file: ./coverage.xml - - - name: Set up Python 3.7 - uses: actions/setup-python@master - with: - python-version: 3.7 - - name: Install dependencies - run: | - python --version - python -m pip install --upgrade pip - pip install -r requirements/test.txt - - name: Test with pytest - run: | - pip install pytest - pip install pytest-cov - pytest diff --git a/pyproject.toml b/pyproject.toml index f513b35..ccee4c7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -32,10 +32,9 @@ module="secret_loader" author="Moritz Eilfort" author-email="secret-loader@jimfawkes.com" home-page="https://github.com/JimFawkes/secret-loader" -requires=[ - "boto3==1.13.16", - "botocore==1.16.16", - "python-dotenv==0.13.0", +requires= [ + "boto3 <1.27, >1.13", + "python-dotenv <0.22, >0.13", ] requires-python=">=3.7" description-file="README.md" @@ -49,9 +48,10 @@ classifiers=[ ] [tool.flit.metadata.requires-extra] -test=[ - "pytest==5.4.2", - "pytest-cov", +test= [ + "pytest==7.2.0", + "pytest-cov==4.0.0" + ] [tool.flit.entrypoints.console_scripts] diff --git a/requirements-dev.txt b/requirements-dev.txt new file mode 100644 index 0000000..4fc3ec3 --- /dev/null +++ b/requirements-dev.txt @@ -0,0 +1,17 @@ +# Development Requirements + +# Base +boto3==1.26.35 +python-dotenv==0.21.0 + +# Testing +pytest==7.2.0 +pytest-cov==4.0.0 + +# Formatting, Liniting, etc. +black==22.12 +bandit==1.7.4 +mypy==0.991 +pre-commit==2.20.0 +pyflakes==3.0.1 +pylama==8.4.1 diff --git a/requirements/base.txt b/requirements/base.txt deleted file mode 100644 index 36de843..0000000 --- a/requirements/base.txt +++ /dev/null @@ -1,2 +0,0 @@ -boto3<1.27,>1.13 -python-dotenv<0.22,>0.13 diff --git a/requirements/local.txt b/requirements/local.txt deleted file mode 100644 index 70abfb2..0000000 --- a/requirements/local.txt +++ /dev/null @@ -1,10 +0,0 @@ -# Requirements for the local env -# Inherit from test and base --r test.txt - -black==22.12 -bandit==1.7.4 -mypy==0.991 -pre-commit==2.20.0 -pyflakes==3.0.1 -pylama==8.4.1 diff --git a/requirements/prod.txt b/requirements/prod.txt deleted file mode 100644 index 0e780bb..0000000 --- a/requirements/prod.txt +++ /dev/null @@ -1,2 +0,0 @@ -# Production Requirements --r base.txt diff --git a/requirements/test.txt b/requirements/test.txt deleted file mode 100644 index 2713c49..0000000 --- a/requirements/test.txt +++ /dev/null @@ -1,5 +0,0 @@ -# Requirements to run tests (Local or CI) --r base.txt - -pytest==7.2.0 -tox==4.0.16 From 575789ba768308f4ee06a9ea62b9ef1fcf2df173 Mon Sep 17 00:00:00 2001 From: Jim Fawkes Date: Thu, 22 Dec 2022 15:45:49 +0100 Subject: [PATCH 3/5] Upgrade Python and Package Version --- .github/workflows/ci.yml | 14 ++++++++------ .pre-commit-config.yaml | 3 +-- README.md | 2 +- pyproject.toml | 9 +++++---- secret_loader/__init__.py | 7 ++----- 5 files changed, 17 insertions(+), 18 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9e2930d..2e10686 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,17 +5,19 @@ on: [push] jobs: build: - runs-on: ${{ matrix.os }} + runs-on: ubuntu-latest strategy: matrix: - os: [ubuntu-latest] + python-version: ["3.9", "3.10", "3.11"] steps: - - uses: actions/checkout@master - - name: Set up Python 3.8 - uses: actions/setup-python@master + - uses: actions/checkout@v3 + + - name: Set up Python + uses: actions/setup-python@v4 with: - python-version: 3.8 + python-version: ${{ matrix.python-version }} + - name: Install dependencies run: | python --version diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 21c7bc0..ad037fe 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,5 @@ repos: - repo: https://github.com/psf/black - rev: stable + rev: 22.12.0 hooks: - id: black - language_version: python3.8 diff --git a/README.md b/README.md index ff22c0d..9cd259e 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ [![test-action](https://github.com/JimFawkes/utils/workflows/run-tests/badge.svg)](https://github.com/JimFawkes/secret-loader/actions) [![codecov](https://codecov.io/gh/JimFawkes/utils/branch/master/graph/badge.svg)](https://codecov.io/gh/JimFawkes/secret-loader) -![python](https://img.shields.io/badge/python-3.7%20|%203.8-blue) +![python](https://img.shields.io/badge/python-3.9%20|%203.10%20|%203.11-blue) [![black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black) [![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](COPYING) [![Latest Tag](https://img.shields.io/github/v/tag/jimfawkes/secret-loader)](https://github.com/JimFawkes/secret-loader/releases) diff --git a/pyproject.toml b/pyproject.toml index ccee4c7..0f85b81 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,7 +6,7 @@ [tool.black] line-length = 100 -target-version = ["py38"] +target-version = ["py310"] include = '\.pyi?$' exclude = ''' /( @@ -36,14 +36,15 @@ requires= [ "boto3 <1.27, >1.13", "python-dotenv <0.22, >0.13", ] -requires-python=">=3.7" +requires-python=">=3.9" description-file="README.md" classifiers=[ "Intended Audience :: Developers", 'Natural Language :: English', "License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)", - "Programming Language :: Python :: 3.7", - "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", "Topic :: Software Development :: Libraries :: Python Modules", ] diff --git a/secret_loader/__init__.py b/secret_loader/__init__.py index 4a94932..365b885 100644 --- a/secret_loader/__init__.py +++ b/secret_loader/__init__.py @@ -5,17 +5,14 @@ GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) """ -__version__ = "0.5" +__version__ = "0.6" __author__ = "Moritz Eilfort" __author_email__ = "secret-loader@jimfawkes.com" __url__ = "github.com/JimFawkes/secret-loader" __license__ = "GPLv3+" __copyright__ = f"Copyright 2020 {__author__}" -from . import loaders -from . import base -from . import exceptions -from . import secrets +from . import base, exceptions, loaders, secrets secret = secrets.secret From 80cdf5685c6401b932752be10719a60952930b15 Mon Sep 17 00:00:00 2001 From: Jim Fawkes Date: Thu, 22 Dec 2022 15:48:48 +0100 Subject: [PATCH 4/5] Re-format using up-to-date black --- secret_loader/cli.py | 20 ++++++++++++++------ secret_loader/loaders.py | 2 +- secret_loader/secrets.py | 10 +++------- 3 files changed, 18 insertions(+), 14 deletions(-) diff --git a/secret_loader/cli.py b/secret_loader/cli.py index a6251a4..8f0fd67 100644 --- a/secret_loader/cli.py +++ b/secret_loader/cli.py @@ -16,13 +16,13 @@ """ import argparse -import logging import importlib +import logging import sys -from secret_loader.secrets import secret, SecretLoader +from secret_loader import __author__, __copyright__, __license__, __url__, __version__ from secret_loader.exceptions import SecretNotFoundError -from secret_loader import __version__, __author__, __url__, __license__, __copyright__ +from secret_loader.secrets import SecretLoader, secret epilog = f""" Version {__version__} - June 2020 - {__author__} - src: {__url__} @@ -46,7 +46,10 @@ ) parser.add_argument( - "--name", "-n", help="Name of Secret to Load", type=str, + "--name", + "-n", + help="Name of Secret to Load", + type=str, ) parser.add_argument("--fail", help="Fail if Secret is not Found", action="store_true") @@ -72,11 +75,16 @@ ) parser.add_argument( - "--remove_loaders", help="Remove pre-registered Loaders", action="store_true", + "--remove_loaders", + help="Remove pre-registered Loaders", + action="store_true", ) parser.add_argument( - "--list_loaders", "-l", help="List all currently available loaders", action="store_true", + "--list_loaders", + "-l", + help="List all currently available loaders", + action="store_true", ) diff --git a/secret_loader/loaders.py b/secret_loader/loaders.py index ebd02df..02f3968 100644 --- a/secret_loader/loaders.py +++ b/secret_loader/loaders.py @@ -17,8 +17,8 @@ import os import boto3.session -from botocore.exceptions import ClientError import dotenv +from botocore.exceptions import ClientError from .base import BaseLoader, pretty_print_function from .exceptions import SecretNotFoundError diff --git a/secret_loader/secrets.py b/secret_loader/secrets.py index 4dd48e5..9d4ccfc 100644 --- a/secret_loader/secrets.py +++ b/secret_loader/secrets.py @@ -3,16 +3,12 @@ GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) """ -from collections import namedtuple import logging +from collections import namedtuple from .base import BaseClass, pretty_print_function -from .exceptions import ( - SecretNotFoundError, - NoLoaderConfiguredError, - ConstructLoaderError, -) -from .loaders import EnvLoader, EnvFileLoader, AWSSecretsLoader +from .exceptions import ConstructLoaderError, NoLoaderConfiguredError, SecretNotFoundError +from .loaders import AWSSecretsLoader, EnvFileLoader, EnvLoader logger = logging.getLogger("secret_loader.secrets") From e24949457a7cd5bd468749361305fc632b95612b Mon Sep 17 00:00:00 2001 From: Jim Fawkes Date: Thu, 22 Dec 2022 16:01:39 +0100 Subject: [PATCH 5/5] Update pre-commit config --- .pre-commit-config.yaml | 33 ++++++++++++++++++++++++++++++++- pyproject.toml | 3 +++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ad037fe..08a335f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,5 +1,36 @@ +default_language_version: + python: python3 + repos: - repo: https://github.com/psf/black - rev: 22.12.0 + rev: "22.12.0" hooks: - id: black + + - repo: https://github.com/pycqa/isort + rev: "5.11.4" + hooks: + - id: isort + + - repo: https://github.com/pre-commit/mirrors-mypy + rev: "v0.991" + hooks: + - id: mypy + + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: "v4.3.0" + hooks: + - id: check-added-large-files + - id: check-case-conflict + - id: debug-statements + - id: end-of-file-fixer + - id: mixed-line-ending + - id: requirements-txt-fixer + - id: trailing-whitespace + + - repo: https://github.com/pre-commit/pygrep-hooks + rev: "v1.9.0" + hooks: + - id: python-no-log-warn + - id: python-no-eval + - id: python-use-type-annotations diff --git a/pyproject.toml b/pyproject.toml index 0f85b81..5bb6f3f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -23,6 +23,9 @@ exclude = ''' )/ ''' +[tool.mypy] +ignore_missing_imports=true + [build-system] requires = ["flit_core >=2,<4"] build-backend = "flit_core.buildapi"