From d23469cc2cd23d3e33a8fab2760fc9d91ba7ca27 Mon Sep 17 00:00:00 2001 From: Jakob Keller <57402305+jakob-keller@users.noreply.github.com> Date: Sat, 21 Oct 2023 22:56:41 +0200 Subject: [PATCH 01/10] bump dev dependencies --- pytest.ini | 1 + requirements-dev.in | 16 ++++++++-------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/pytest.ini b/pytest.ini index eb657022..8407bd1f 100644 --- a/pytest.ini +++ b/pytest.ini @@ -1,4 +1,5 @@ [pytest] +asyncio_mode = auto cache_dir = /tmp/pytest_aiobotocore_cache markers = moto diff --git a/requirements-dev.in b/requirements-dev.in index d050be5a..d082b5f4 100644 --- a/requirements-dev.in +++ b/requirements-dev.in @@ -1,16 +1,16 @@ codecov~=2.1.13 -coverage~=7.2.7 -flake8~=3.9.0 +coverage~=7.3.2 +flake8~=6.1.0 flake8-black~=0.3.3 -flake8-isort~= 4.1.1 -black~=22.6.0 -isort~= 5.10.1 +flake8-isort~= 6.1.0 +black~=23.10.0 +isort~= 5.12.0 docker~=6.1.3 moto[server,s3,sqs,lambda,dynamodb,cloudformation,sns,batch,ec2,rds]~=4.0.0 -pytest~=6.2.4 +pytest~=7.4.2 pytest-cov~=4.1.0 -pytest-asyncio~=0.14.0 -pytest-xdist~=2.2.1 +pytest-asyncio~=0.21.1 +pytest-xdist~=3.3.1 # this is needed for test_patches dill~=0.3.3 From 89066629f1213f781d31e7a549c945e08badf2f1 Mon Sep 17 00:00:00 2001 From: Jakob Keller <57402305+jakob-keller@users.noreply.github.com> Date: Mon, 23 Oct 2023 19:34:32 +0200 Subject: [PATCH 02/10] apply latest `black` formatting rules --- aiobotocore/credentials.py | 2 -- aiobotocore/session.py | 10 +++------- examples/simple.py | 1 - examples/sqs_queue_create.py | 1 - tests/boto_tests/test_credentials.py | 2 -- tests/python3.8/boto_tests/test_signers.py | 2 -- tests/test_config.py | 1 - tests/test_patches.py | 1 - tests/test_session.py | 1 - 9 files changed, 3 insertions(+), 18 deletions(-) diff --git a/aiobotocore/credentials.py b/aiobotocore/credentials.py index 5e535ac8..0778b7ab 100644 --- a/aiobotocore/credentials.py +++ b/aiobotocore/credentials.py @@ -438,7 +438,6 @@ async def _create_client(self): ) -# black: # fmt: skip (ing) this line triggers internal black error class AioAssumeRoleWithWebIdentityCredentialFetcher( AioBaseAssumeRoleCredentialFetcher ): @@ -451,7 +450,6 @@ def __init__( cache=None, expiry_window_seconds=None, ): - self._web_identity_token_loader = web_identity_token_loader super().__init__( diff --git a/aiobotocore/session.py b/aiobotocore/session.py index d480ca51..fcae6996 100644 --- a/aiobotocore/session.py +++ b/aiobotocore/session.py @@ -32,7 +32,6 @@ async def __aexit__(self, exc_type, exc_val, exc_tb): class AioSession(Session): - # noinspection PyMissingConstructor def __init__( self, @@ -80,11 +79,9 @@ def set_credentials(self, access_key, secret_key, token=None): async def get_credentials(self): if self._credentials is None: - self._credentials = await ( - self._components.get_component( - 'credential_provider' - ).load_credentials() - ) + self._credentials = await self._components.get_component( + 'credential_provider' + ).load_credentials() return self._credentials async def get_service_model(self, service_name, api_version=None): @@ -126,7 +123,6 @@ async def _create_client( aws_session_token=None, config=None, ): - default_client_config = self.get_default_client_config() # If a config is provided and a default config is set, then # use the config resulting from merging the two. diff --git a/examples/simple.py b/examples/simple.py index 3c1e79e6..3d41c891 100644 --- a/examples/simple.py +++ b/examples/simple.py @@ -7,7 +7,6 @@ async def go(): - bucket = 'dataintake' filename = 'dummy.bin' folder = 'aiobotocore' diff --git a/examples/sqs_queue_create.py b/examples/sqs_queue_create.py index aead4925..eb7b6bc8 100644 --- a/examples/sqs_queue_create.py +++ b/examples/sqs_queue_create.py @@ -7,7 +7,6 @@ async def go(): session = get_session() async with session.create_client('sqs', region_name='us-west-2') as client: - print('Creating test_queue1') response = await client.create_queue(QueueName='test_queue1') queue_url = response['QueueUrl'] diff --git a/tests/boto_tests/test_credentials.py b/tests/boto_tests/test_credentials.py index c332bbd9..5711c63d 100644 --- a/tests/boto_tests/test_credentials.py +++ b/tests/boto_tests/test_credentials.py @@ -465,7 +465,6 @@ async def test_assumerolecredprovider_assume_role_no_cache( async def test_assumerolecredprovider_mfa( credential_provider, assumerolecredprovider_config_loader ): - fake_config = { 'profiles': { 'development': { @@ -525,7 +524,6 @@ async def test_assumerolecredprovider_mfa( async def test_assumerolecredprovider_mfa_cannot_refresh_credentials( credential_provider, assumerolecredprovider_config_loader ): - fake_config = { 'profiles': { 'development': { diff --git a/tests/python3.8/boto_tests/test_signers.py b/tests/python3.8/boto_tests/test_signers.py index fa006c00..e359ffde 100644 --- a/tests/python3.8/boto_tests/test_signers.py +++ b/tests/python3.8/boto_tests/test_signers.py @@ -78,7 +78,6 @@ async def test_signers_generate_presigned_urls(): aws_secret_access_key='lalala', aws_session_token='lalala', ) as client: - # Uses HEAD as it covers more lines :) await client.generate_presigned_url( 'get_object', @@ -123,7 +122,6 @@ async def test_signers_generate_presigned_post(): aws_secret_access_key='lalala', aws_session_token='lalala', ) as client: - await client.generate_presigned_post( 'somebucket', 'someprefix/key' ) diff --git a/tests/test_config.py b/tests/test_config.py index 98edd83e..fab971e9 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -112,7 +112,6 @@ async def test_connector_timeout2(): aws_secret_access_key='xxx', aws_access_key_id='xxx', ) as s3_client: - with pytest.raises(ReadTimeoutError): resp = await s3_client.get_object(Bucket='foo', Key='bar') await resp["Body"].read() diff --git a/tests/test_patches.py b/tests/test_patches.py index 80c348b7..7d945c07 100644 --- a/tests/test_patches.py +++ b/tests/test_patches.py @@ -671,7 +671,6 @@ def test_patches(): success = True for obj, digests in _API_DIGESTS.items(): - try: source = getsource(obj) except TypeError: diff --git a/tests/test_session.py b/tests/test_session.py index 8259ef66..4c3f5874 100644 --- a/tests/test_session.py +++ b/tests/test_session.py @@ -47,7 +47,6 @@ async def test_retry( aws_access_key_id="xxx", endpoint_url='http://localhost:7878', ) as client: - # this needs the new style exceptions to work with pytest.raises(httpsession.EndpointConnectionError): await client.get_object(Bucket='foo', Key='bar') From ba267f62b37d306c9b534cdd426e467504e48b9d Mon Sep 17 00:00:00 2001 From: Jakob Keller <57402305+jakob-keller@users.noreply.github.com> Date: Mon, 23 Oct 2023 19:50:04 +0200 Subject: [PATCH 03/10] fix type annotation --- tests/test_version.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/test_version.py b/tests/test_version.py index a490c299..79cde86a 100644 --- a/tests/test_version.py +++ b/tests/test_version.py @@ -87,7 +87,9 @@ def _get_boto_module_versions( continue # NOTE: don't support complex versioning yet as requirements are unknown - gte = lt = eq = None # type: Optional[version.Version] + gte: Optional[version.Version] = None + lt: Optional[version.Version] = None + eq: Optional[version.Version] = None for spec in ver.req.specifier: if spec.operator == '>=': assert gte is None From 0c2a0d2679e1380cb889d5179e4393ce36973ec0 Mon Sep 17 00:00:00 2001 From: Jakob Keller <57402305+jakob-keller@users.noreply.github.com> Date: Mon, 23 Oct 2023 20:19:48 +0200 Subject: [PATCH 04/10] add pre-commit dev dependency --- requirements-dev.in | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements-dev.in b/requirements-dev.in index d082b5f4..0ec3d1fc 100644 --- a/requirements-dev.in +++ b/requirements-dev.in @@ -7,6 +7,7 @@ black~=23.10.0 isort~= 5.12.0 docker~=6.1.3 moto[server,s3,sqs,lambda,dynamodb,cloudformation,sns,batch,ec2,rds]~=4.0.0 +pre-commit~=3.5.0 pytest~=7.4.2 pytest-cov~=4.1.0 pytest-asyncio~=0.21.1 From b1cd3cb5c2d56a7bb453be994417737c7ede561f Mon Sep 17 00:00:00 2001 From: Jakob Keller <57402305+jakob-keller@users.noreply.github.com> Date: Mon, 23 Oct 2023 20:20:46 +0200 Subject: [PATCH 05/10] align pre-commit hooks with upstream --- .pre-commit-config.yaml | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index f11d292a..06c3cdc2 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,25 +1,25 @@ repos: - repo: 'https://github.com/pre-commit/pre-commit-hooks' - rev: v4.3.0 + rev: v4.4.0 hooks: - id: check-yaml - id: end-of-file-fixer - id: trailing-whitespace - - repo: 'https://github.com/asottile/pyupgrade' - rev: v2.37.3 - hooks: - - id: pyupgrade - args: - - '--py38-plus' - - repo: 'https://github.com/psf/black' - rev: 22.8.0 - hooks: - - id: black - repo: 'https://github.com/PyCQA/isort' rev: 5.12.0 hooks: - id: isort - repo: 'https://github.com/pycqa/flake8' - rev: 5.0.4 + rev: 6.0.0 hooks: - id: flake8 + - repo: 'https://github.com/asottile/pyupgrade' + rev: v3.3.2 + hooks: + - id: pyupgrade + args: + - '--py36-plus' + - repo: 'https://github.com/psf/black' + rev: 23.3.0 + hooks: + - id: black From 5eccb17b6224249c76e2a02e3f1263dd9255501d Mon Sep 17 00:00:00 2001 From: Jakob Keller <57402305+jakob-keller@users.noreply.github.com> Date: Mon, 23 Oct 2023 20:56:42 +0200 Subject: [PATCH 06/10] align pytest config with upstream --- pyproject.toml | 9 +++++++++ pytest.ini | 7 ------- 2 files changed, 9 insertions(+), 7 deletions(-) delete mode 100644 pytest.ini diff --git a/pyproject.toml b/pyproject.toml index f23d8c48..1fd00b96 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,12 @@ +[tool.pytest.ini_options] +asyncio_mode = "auto" +cache_dir = "/tmp/pytest_aiobotocore_cache" +markers = [ + "moto", + "config_kwargs", + "patch_attributes", +] + [tool.isort] profile = "black" line_length = 79 diff --git a/pytest.ini b/pytest.ini deleted file mode 100644 index 8407bd1f..00000000 --- a/pytest.ini +++ /dev/null @@ -1,7 +0,0 @@ -[pytest] -asyncio_mode = auto -cache_dir = /tmp/pytest_aiobotocore_cache -markers = - moto - config_kwargs - patch_attributes From 5011b07a3e3213f47e8b4f50fcbab0ee43dc48b1 Mon Sep 17 00:00:00 2001 From: Jakob Keller <57402305+jakob-keller@users.noreply.github.com> Date: Mon, 23 Oct 2023 20:57:01 +0200 Subject: [PATCH 07/10] align flake8 config with upstream --- .flake8 => setup.cfg | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .flake8 => setup.cfg (100%) diff --git a/.flake8 b/setup.cfg similarity index 100% rename from .flake8 rename to setup.cfg From 11dc1df8091e19f4455a3d00e9dbd83e21e774ba Mon Sep 17 00:00:00 2001 From: Jakob Keller <57402305+jakob-keller@users.noreply.github.com> Date: Mon, 23 Oct 2023 21:02:34 +0200 Subject: [PATCH 08/10] run flake8, black, isort through pre-commit --- .github/workflows/python-package.yml | 4 ++-- Makefile | 10 +++++----- requirements-dev.in | 5 ----- 3 files changed, 7 insertions(+), 12 deletions(-) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 1dbafd40..de5da3dd 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -44,10 +44,10 @@ jobs: python -m pip install -U setuptools pip codecov wheel pip-tools time pip-compile requirements-dev.in time pip-sync requirements-dev.txt - - name: Run flake + - name: Run pre-commit hooks if: matrix.python-version == '3.11' run: | - make flake + make pre-commit - name: Run unittests env: COLOR: 'yes' diff --git a/Makefile b/Makefile index e383a892..3bf31f10 100644 --- a/Makefile +++ b/Makefile @@ -2,10 +2,10 @@ FLAGS= -flake: checkrst - python -m flake8 +pre-commit flake: checkrst + pre-commit run --all -test: flake +test: pre-commit python -Wd -m pytest -s -vv $(FLAGS) ./tests/ vtest: @@ -14,7 +14,7 @@ vtest: checkrst: python setup.py check -rms -cov cover coverage: flake +cov cover coverage: pre-commit python -Wd -m pytest -s -vv --cov-report term --cov-report html --cov aiobotocore ./tests @echo "open file://`pwd`/htmlcov/index.html" @@ -48,4 +48,4 @@ doc: make -C docs html @echo "open file://`pwd`/docs/_build/html/index.html" -.PHONY: all flake test vtest cov clean doc +.PHONY: all pre-commit test vtest cov clean doc diff --git a/requirements-dev.in b/requirements-dev.in index 0ec3d1fc..f8185e91 100644 --- a/requirements-dev.in +++ b/requirements-dev.in @@ -1,10 +1,5 @@ codecov~=2.1.13 coverage~=7.3.2 -flake8~=6.1.0 -flake8-black~=0.3.3 -flake8-isort~= 6.1.0 -black~=23.10.0 -isort~= 5.12.0 docker~=6.1.3 moto[server,s3,sqs,lambda,dynamodb,cloudformation,sns,batch,ec2,rds]~=4.0.0 pre-commit~=3.5.0 From 6b9fcda090f8f05f6f4d40fd2c0606f678f5c219 Mon Sep 17 00:00:00 2001 From: Jakob Keller <57402305+jakob-keller@users.noreply.github.com> Date: Mon, 23 Oct 2023 21:03:17 +0200 Subject: [PATCH 09/10] align dev dependencies with upstream --- requirements-dev.in | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/requirements-dev.in b/requirements-dev.in index f8185e91..e68f8bbb 100644 --- a/requirements-dev.in +++ b/requirements-dev.in @@ -1,12 +1,12 @@ codecov~=2.1.13 -coverage~=7.3.2 +coverage==7.2.7 docker~=6.1.3 moto[server,s3,sqs,lambda,dynamodb,cloudformation,sns,batch,ec2,rds]~=4.0.0 pre-commit~=3.5.0 -pytest~=7.4.2 -pytest-cov~=4.1.0 +pytest==7.4.0 +pytest-cov==4.1.0 pytest-asyncio~=0.21.1 -pytest-xdist~=3.3.1 +pytest-xdist==3.3.1 # this is needed for test_patches dill~=0.3.3 From e84b5368048fe1b26fc6b697fd3139a152f2b6ec Mon Sep 17 00:00:00 2001 From: Jakob Keller <57402305+jakob-keller@users.noreply.github.com> Date: Mon, 23 Oct 2023 21:05:52 +0200 Subject: [PATCH 10/10] add setuptools to dev dependencies for Python 3.12 --- requirements-dev.in | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements-dev.in b/requirements-dev.in index e68f8bbb..61ebaf43 100644 --- a/requirements-dev.in +++ b/requirements-dev.in @@ -7,6 +7,7 @@ pytest==7.4.0 pytest-cov==4.1.0 pytest-asyncio~=0.21.1 pytest-xdist==3.3.1 +setuptools==67.8.0;python_version>="3.12" # this is needed for test_patches dill~=0.3.3