From 64144ae04326d115e50937a79b7f7772f8d428ee Mon Sep 17 00:00:00 2001 From: Fantix King Date: Tue, 28 May 2024 14:28:02 -0400 Subject: [PATCH 1/5] test: fix teardown order of asyncio server and client --- tests/test_asyncio_client.py | 2 +- tests/test_blocking_client.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_asyncio_client.py b/tests/test_asyncio_client.py index 13e7c843c..b4d5b03d1 100644 --- a/tests/test_asyncio_client.py +++ b/tests/test_asyncio_client.py @@ -442,9 +442,9 @@ async def cb(r: asyncio.StreamReader, w: asyncio.StreamWriter): try: await self._test_connection_broken(client, broken) finally: + await asyncio.wait_for(client.aclose(), 5) server.close() await server.wait_closed() - await asyncio.wait_for(client.aclose(), 5) broken.set() await done.wait() diff --git a/tests/test_blocking_client.py b/tests/test_blocking_client.py index 396356b52..099baa719 100644 --- a/tests/test_blocking_client.py +++ b/tests/test_blocking_client.py @@ -453,9 +453,9 @@ async def cb(r: asyncio.StreamReader, w: asyncio.StreamWriter): None, self._test_connection_broken, client, broken ) finally: + await self.loop.run_in_executor(None, client.close, 5) server.close() await server.wait_closed() - await self.loop.run_in_executor(None, client.close, 5) broken.set() await done.wait() From 7bb67e8c5465da48f5e8c88030f59c4b2badf5a8 Mon Sep 17 00:00:00 2001 From: Fantix King Date: Tue, 28 May 2024 14:29:04 -0400 Subject: [PATCH 2/5] test: add Python 3.12 --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 5dfe60419..28cb0d538 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -25,7 +25,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ["3.8", "3.9", "3.10", "3.11"] + python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] edgedb-version: [stable , nightly] os: [ubuntu-latest, macos-latest, windows-2019] loop: [asyncio, uvloop] From 3422dfb5b00b9ff296f75b145e6700778b523535 Mon Sep 17 00:00:00 2001 From: Fantix King Date: Tue, 28 May 2024 14:35:43 -0400 Subject: [PATCH 3/5] Fix flake8 --- tests/datatypes/test_datatypes.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/datatypes/test_datatypes.py b/tests/datatypes/test_datatypes.py index 93bbcd175..3cedc7058 100644 --- a/tests/datatypes/test_datatypes.py +++ b/tests/datatypes/test_datatypes.py @@ -60,7 +60,7 @@ def test_recorddesc_1(self): private._RecordDescriptor(('a', 'b')) - with self.assertRaisesRegex(ValueError, f'more than {0x4000-1}'): + with self.assertRaisesRegex(ValueError, f'more than {0x4000 - 1}'): private._RecordDescriptor(('a',) * 20000) def test_recorddesc_2(self): From aa501baa5540ad725364c8298d0630fb1524cad5 Mon Sep 17 00:00:00 2001 From: Fantix King Date: Tue, 28 May 2024 14:40:01 -0400 Subject: [PATCH 4/5] Bump test deps --- setup.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/setup.py b/setup.py index 8884fed2a..c5d0ebbb8 100644 --- a/setup.py +++ b/setup.py @@ -45,10 +45,10 @@ # pycodestyle is a dependency of flake8, but it must be frozen because # their combination breaks too often # (example breakage: https://gitlab.com/pycqa/flake8/issues/427) - 'pycodestyle~=2.6.0', - 'pyflakes~=2.2.0', - 'flake8-bugbear~=21.4.3', - 'flake8~=3.8.1', + 'pycodestyle~=2.11.1', + 'pyflakes~=3.2.0', + 'flake8-bugbear~=24.4.26', + 'flake8~=7.0.0', 'uvloop>=0.15.1; platform_system != "Windows"', ] From d1311484360bed890ee939b60000adf3d9cfffe7 Mon Sep 17 00:00:00 2001 From: Fantix King Date: Tue, 28 May 2024 15:04:44 -0400 Subject: [PATCH 5/5] Fix flake8 issues --- .flake8 | 2 +- edgedb/abstract.py | 1 + edgedb/blocking_client.py | 7 +++---- edgedb/color.py | 3 ++- edgedb/con_utils.py | 2 +- edgedb/errors/_base.py | 3 ++- tests/test_async_query.py | 2 +- tests/test_sync_query.py | 2 +- 8 files changed, 12 insertions(+), 10 deletions(-) diff --git a/.flake8 b/.flake8 index b9934d04b..ae5a762d0 100644 --- a/.flake8 +++ b/.flake8 @@ -1,3 +1,3 @@ [flake8] -ignore = B008,B306,E203,E402,E731,D100,D101,D102,D103,D104,D105,W503,W504,E252,F999,F541 +ignore = B008,B023,B306,E203,E402,E731,D100,D101,D102,D103,D104,D105,W503,W504,E252,F999,F541 exclude = .git,__pycache__,build,dist,.eggs diff --git a/edgedb/abstract.py b/edgedb/abstract.py index ba9a3f6c8..7e8f4f6a8 100644 --- a/edgedb/abstract.py +++ b/edgedb/abstract.py @@ -131,6 +131,7 @@ def _get_query_cache(self) -> QueryCache: def _get_retry_options(self) -> typing.Optional[options.RetryOptions]: return None + @abc.abstractmethod def _get_state(self) -> options.State: ... diff --git a/edgedb/blocking_client.py b/edgedb/blocking_client.py index aafccab85..979315012 100644 --- a/edgedb/blocking_client.py +++ b/edgedb/blocking_client.py @@ -102,10 +102,9 @@ async def connect_addr(self, addr, timeout): self._addr = addr self._ping_wait_time = max( ( - getattr( - self.get_settings().get("system_config"), - "session_idle_timeout", - ) + self.get_settings() + .get("system_config") + .session_idle_timeout - DEFAULT_PING_BEFORE_IDLE_TIMEOUT ), MINIMUM_PING_WAIT_TIME, diff --git a/edgedb/color.py b/edgedb/color.py index 1e95c7bf1..2b972aaa8 100644 --- a/edgedb/color.py +++ b/edgedb/color.py @@ -55,6 +55,7 @@ def get_color() -> Color: except KeyError: warnings.warn( "EDGEDB_COLOR_OUTPUT can only be one of: " - "default, auto, enabled or disabled" + "default, auto, enabled or disabled", + stacklevel=1, ) USE_COLOR = False diff --git a/edgedb/con_utils.py b/edgedb/con_utils.py index fa9395021..c359a0568 100644 --- a/edgedb/con_utils.py +++ b/edgedb/con_utils.py @@ -641,7 +641,7 @@ def _parse_connect_dsn_and_args( ): # EDGEDB_PORT is set by 'docker --link' so ignore and warn warnings.warn('EDGEDB_PORT in "tcp://host:port" format, ' + - 'so will be ignored') + 'so will be ignored', stacklevel=1) env_port = None env_dsn = os.getenv('EDGEDB_DSN') diff --git a/edgedb/errors/_base.py b/edgedb/errors/_base.py index cd1d7f794..11f5c26d9 100644 --- a/edgedb/errors/_base.py +++ b/edgedb/errors/_base.py @@ -331,7 +331,8 @@ def _unicode_width(text): ] except KeyError: warnings.warn( - "EDGEDB_ERROR_HINT can only be one of: default, enabled or disabled" + "EDGEDB_ERROR_HINT can only be one of: default, enabled or disabled", + stacklevel=1, ) SHOW_HINT = False diff --git a/tests/test_async_query.py b/tests/test_async_query.py index 39b2dd7ba..0720dc1dc 100644 --- a/tests/test_async_query.py +++ b/tests/test_async_query.py @@ -87,7 +87,7 @@ async def test_async_parse_error_recover_02(self): await self.client.execute('select syntax error') for _ in range(10): - await self.client.execute('select 1; select 2;'), + await self.client.execute('select 1; select 2;') async def test_async_exec_error_recover_01(self): for _ in range(2): diff --git a/tests/test_sync_query.py b/tests/test_sync_query.py index 79dae829b..2b03797eb 100644 --- a/tests/test_sync_query.py +++ b/tests/test_sync_query.py @@ -75,7 +75,7 @@ def test_sync_parse_error_recover_02(self): self.client.execute('select syntax error') for _ in range(10): - self.client.execute('select 1; select 2;'), + self.client.execute('select 1; select 2;') def test_sync_exec_error_recover_01(self): for _ in range(2):