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/.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 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/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/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 eb657022..00000000 --- a/pytest.ini +++ /dev/null @@ -1,6 +0,0 @@ -[pytest] -cache_dir = /tmp/pytest_aiobotocore_cache -markers = - moto - config_kwargs - patch_attributes diff --git a/requirements-dev.in b/requirements-dev.in index d050be5a..61ebaf43 100644 --- a/requirements-dev.in +++ b/requirements-dev.in @@ -1,16 +1,13 @@ codecov~=2.1.13 -coverage~=7.2.7 -flake8~=3.9.0 -flake8-black~=0.3.3 -flake8-isort~= 4.1.1 -black~=22.6.0 -isort~= 5.10.1 +coverage==7.2.7 docker~=6.1.3 moto[server,s3,sqs,lambda,dynamodb,cloudformation,sns,batch,ec2,rds]~=4.0.0 -pytest~=6.2.4 -pytest-cov~=4.1.0 -pytest-asyncio~=0.14.0 -pytest-xdist~=2.2.1 +pre-commit~=3.5.0 +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 diff --git a/.flake8 b/setup.cfg similarity index 100% rename from .flake8 rename to setup.cfg 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') 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