diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 807a11b..be8f6df 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -19,7 +19,7 @@ jobs: python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v4 with: @@ -27,7 +27,6 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - python -m pip install flake8 pip install -r requirements.txt -r dev-requirements.txt pip install -e . - name: Lint with flake8 @@ -36,6 +35,8 @@ jobs: flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + - name: Lint with PyLint + run: pylint --rcfile=.pylintrc src/aws_secretsmanager_caching - name: Test with pytest run: | pytest test/unit/ diff --git a/README.md b/README.md index 6328671..518280b 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,7 @@ To use this client you must have: This library requires the following standard dependencies: * botocore * setuptools_scm +* setuptools For development and testing purposes, this library requires the following additional dependencies: * pytest @@ -31,6 +32,8 @@ For development and testing purposes, this library requires the following additi * codecov * pylint * sphinx +* flake8 +* tox Please review the `requirements.txt` and `dev-requirements.txt` file for specific version requirements. diff --git a/dev-requirements.txt b/dev-requirements.txt index e9066c4..5badd8e 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -1,6 +1,8 @@ -pytest -pytest-cov -pytest-sugar +pytest>=8 +pytest-cov>=5 +pytest-sugar>=1 codecov>=1.4.0 pylint>1.9.4 sphinx>=1.8.4 +tox>=4 +flake8>=7 diff --git a/doc/conf.py b/doc/conf.py index 7ac36cc..14a6a3f 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -1,9 +1,8 @@ +from importlib.metadata import version from datetime import datetime -from pkg_resources import get_distribution import os import shutil -version = get_distribution('aws_secretsmanager_caching').version project = u'AWS Secrets Manager Python Caching Client' # If you use autosummary, this ensures that any stale autogenerated files are @@ -32,7 +31,7 @@ copyright = u'%s, Amazon.com' % datetime.now().year # The full version, including alpha/beta/rc tags. -release = version +release = version('aws_secretsmanager_caching') # List of directories, relative to source directory, that shouldn't be searched # for source files. diff --git a/requirements.txt b/requirements.txt index 138d8e6..d1c1a23 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,3 @@ botocore>=1.12 setuptools_scm>=3.2 +setuptools>=69 diff --git a/setup.cfg b/setup.cfg index 34d0603..2f26180 100644 --- a/setup.cfg +++ b/setup.cfg @@ -16,7 +16,7 @@ description-file = README.md license_file = LICENSE [flake8] -max-line-length = 120 +max-line-length = 127 select = C,E,F,W,B # C812, W503 clash with black ignore = C812,W503 diff --git a/src/aws_secretsmanager_caching/cache/items.py b/src/aws_secretsmanager_caching/cache/items.py index b4d5cc4..fb4aec9 100644 --- a/src/aws_secretsmanager_caching/cache/items.py +++ b/src/aws_secretsmanager_caching/cache/items.py @@ -123,7 +123,7 @@ def get_secret_value(self, version_stage=None): if not value and self._exception: raise self._exception return deepcopy(value) - + def refresh_secret_now(self): """Force a refresh of the cached secret. :rtype: None diff --git a/src/aws_secretsmanager_caching/secret_cache.py b/src/aws_secretsmanager_caching/secret_cache.py index ca72996..99c11c1 100644 --- a/src/aws_secretsmanager_caching/secret_cache.py +++ b/src/aws_secretsmanager_caching/secret_cache.py @@ -13,9 +13,9 @@ """High level AWS Secrets Manager caching client.""" from copy import deepcopy +from importlib.metadata import version, PackageNotFoundError import botocore.config import botocore.session -from pkg_resources import DistributionNotFound, get_distribution from .cache import LRUCache, SecretCacheItem from .config import SecretCacheConfig @@ -25,8 +25,8 @@ class SecretCache: """Secret Cache client for AWS Secrets Manager secrets""" try: - __version__ = get_distribution('aws_secretsmanager_caching').version - except DistributionNotFound: + __version__ = version('aws_secretsmanager_caching') + except PackageNotFoundError: __version__ = '0.0.0' def __init__(self, config=SecretCacheConfig(), client=None): diff --git a/test/unit/test_items.py b/test/unit/test_items.py index 3becab0..da93341 100644 --- a/test/unit/test_items.py +++ b/test/unit/test_items.py @@ -73,7 +73,6 @@ def test_refresh_now(self): # The new refresh time will be between now + ttl and now + (ttl / 2) if the secret was immediately refreshed self.assertTrue(new_refresh_time < old_refresh_time and new_refresh_time < datetime.now(timezone.utc) + timedelta(ttl)) - def test_datetime_fix_is_refresh_needed(self): secret_cached_object = TestSecretCacheObject.TestObject(SecretCacheConfig(), None, None) diff --git a/tox.ini b/tox.ini index 7f522c8..29142a9 100644 --- a/tox.ini +++ b/tox.ini @@ -5,7 +5,7 @@ [tox] -envlist = py36, py37, flake8, pylint +envlist = py38, py39, py310, py311, py312, flake8, pylint skip_missing_interpreters = true [testenv]