From a33a13358179f12ed95592a01965b18603633f0c Mon Sep 17 00:00:00 2001 From: Daniel Townsend Date: Wed, 4 Oct 2023 21:09:57 +0100 Subject: [PATCH 1/6] add Python 3.12 support --- .github/workflows/release.yaml | 2 +- .github/workflows/tests.yaml | 14 +++++++------- setup.py | 1 + 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 806b1de20..60f0b83b1 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -14,7 +14,7 @@ jobs: - uses: "actions/checkout@v3" - uses: "actions/setup-python@v1" with: - python-version: 3.11 + python-version: 3.12 - name: "Install dependencies" run: "pip install -r requirements/dev-requirements.txt" - name: "Publish to PyPI" diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 2fd40034c..f2725bea7 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -16,7 +16,7 @@ jobs: timeout-minutes: 30 strategy: matrix: - python-version: ["3.8", "3.9", "3.10", "3.11"] + python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] steps: - uses: actions/checkout@v3 @@ -85,7 +85,7 @@ jobs: timeout-minutes: 30 strategy: matrix: - python-version: ["3.8", "3.9", "3.10", "3.11"] + python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] postgres-version: [11, 12, 13, 14, 15, 16] # Service containers to run with `container-job` @@ -134,14 +134,14 @@ jobs: PG_PASSWORD: postgres - name: Upload coverage uses: codecov/codecov-action@v1 - if: matrix.python-version == '3.11' + if: matrix.python-version == '3.12' cockroach: runs-on: ubuntu-latest timeout-minutes: 30 strategy: matrix: - python-version: ["3.8", "3.9", "3.10", "3.11"] + python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] cockroachdb-version: ["v22.2.0"] steps: - uses: actions/checkout@v3 @@ -168,14 +168,14 @@ jobs: PG_DATABASE: piccolo - name: Upload coverage uses: codecov/codecov-action@v1 - if: matrix.python-version == '3.11' + if: matrix.python-version == '3.12' sqlite: runs-on: ubuntu-latest timeout-minutes: 30 strategy: matrix: - python-version: ["3.8", "3.9", "3.10", "3.11"] + python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] steps: - uses: actions/checkout@v3 @@ -193,4 +193,4 @@ jobs: run: ./scripts/test-sqlite.sh - name: Upload coverage uses: codecov/codecov-action@v1 - if: matrix.python-version == '3.11' + if: matrix.python-version == '3.12' diff --git a/setup.py b/setup.py index 155768811..0996a1297 100644 --- a/setup.py +++ b/setup.py @@ -88,6 +88,7 @@ def extras_require() -> t.Dict[str, t.List[str]]: "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", "Programming Language :: Python :: Implementation :: CPython", "Framework :: AsyncIO", "Typing :: Typed", From 73fdcaeeba2a980d5e38ac9dce2337eadb9f73b1 Mon Sep 17 00:00:00 2001 From: Daniel Townsend Date: Wed, 4 Oct 2023 21:32:32 +0100 Subject: [PATCH 2/6] update flake8 version --- requirements/dev-requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements/dev-requirements.txt b/requirements/dev-requirements.txt index bd8a17e15..cfd4560ca 100644 --- a/requirements/dev-requirements.txt +++ b/requirements/dev-requirements.txt @@ -1,7 +1,7 @@ black==22.3.0 ipdb==0.13.9 ipython>=7.31.1 -flake8==4.0.1 +flake8==6.1.0 isort==5.10.1 slotscheck==0.14.0 twine==3.8.0 From ed4ef2e2733f414db10d1d996f6840769080e52f Mon Sep 17 00:00:00 2001 From: Daniel Townsend Date: Wed, 4 Oct 2023 22:05:49 +0100 Subject: [PATCH 3/6] fix flake8 warnings --- piccolo/query/mixins.py | 8 ++++---- piccolo/querystring.py | 2 +- piccolo/table.py | 2 +- tests/columns/m2m/test_m2m.py | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/piccolo/query/mixins.py b/piccolo/query/mixins.py index ac474b906..56be35a8f 100644 --- a/piccolo/query/mixins.py +++ b/piccolo/query/mixins.py @@ -90,7 +90,7 @@ class Limit: number: int def __post_init__(self): - if type(self.number) != int: + if not isinstance(self.number, int): raise TypeError("Limit must be an integer") @property @@ -111,7 +111,7 @@ class AsOf: interval: str def __post_init__(self): - if type(self.interval) != str: + if not isinstance(self.interval, str): raise TypeError("As Of must be a string. Example: '-1s'") @property @@ -129,8 +129,8 @@ class Offset: number: int def __post_init__(self): - if type(self.number) != int: - raise TypeError("Limit must be an integer") + if not isinstance(self.number, int): + raise TypeError("Offset must be an integer") @property def querystring(self) -> QueryString: diff --git a/piccolo/querystring.py b/piccolo/querystring.py index 7470deb15..3c23d86dc 100644 --- a/piccolo/querystring.py +++ b/piccolo/querystring.py @@ -143,7 +143,7 @@ def bundle( fragment.no_arg = True bundled.append(fragment) else: - if type(value) == self.__class__: + if isinstance(value, self.__class__): fragment.no_arg = True bundled.append(fragment) diff --git a/piccolo/table.py b/piccolo/table.py index ddbe04fa6..92590b2c2 100644 --- a/piccolo/table.py +++ b/piccolo/table.py @@ -794,7 +794,7 @@ def querystring(self) -> QueryString: args_dict[column_name] = value def is_unquoted(arg): - return type(arg) == Unquoted + return isinstance(arg, Unquoted) # Strip out any args which are unquoted. filtered_args = [i for i in args_dict.values() if not is_unquoted(i)] diff --git a/tests/columns/m2m/test_m2m.py b/tests/columns/m2m/test_m2m.py index e928a251f..aaec9fc84 100644 --- a/tests/columns/m2m/test_m2m.py +++ b/tests/columns/m2m/test_m2m.py @@ -395,7 +395,7 @@ def test_select_single(self): original_value = getattr(self.mega_table, column_name) returned_value = data[column_name] - if type(column) == UUID: + if isinstance(column, UUID): self.assertIn(type(returned_value), (uuid.UUID, asyncpgUUID)) else: self.assertEqual( @@ -419,7 +419,7 @@ def test_select_single(self): original_value = getattr(self.mega_table, column_name) returned_value = response[0]["mega_rows"][0] - if type(column) == UUID: + if isinstance(column, UUID): self.assertIn(type(returned_value), (uuid.UUID, asyncpgUUID)) self.assertEqual(str(original_value), str(returned_value)) else: From 3d00fcc299ec8008be4913c740127eb6d99ce751 Mon Sep 17 00:00:00 2001 From: Daniel Townsend Date: Wed, 4 Oct 2023 22:13:00 +0100 Subject: [PATCH 4/6] remove space around f-string variable --- piccolo/apps/migrations/auto/schema_differ.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/piccolo/apps/migrations/auto/schema_differ.py b/piccolo/apps/migrations/auto/schema_differ.py index a8deb2e57..2ee4bd3e1 100644 --- a/piccolo/apps/migrations/auto/schema_differ.py +++ b/piccolo/apps/migrations/auto/schema_differ.py @@ -278,7 +278,7 @@ def check_renamed_columns(self) -> RenameColumnCollection: user_response = self.auto_input or input( f"Did you rename the `{drop_column.db_column_name}` " # noqa: E501 f"column to `{add_column.db_column_name}` on the " - f"`{ add_column.table_class_name }` table? (y/N)" + f"`{add_column.table_class_name}` table? (y/N)" ) if user_response.lower() == "y": used_drop_column_names.append(drop_column.column_name) From d74387be92fe4910bd9fc427812a61542463f1fa Mon Sep 17 00:00:00 2001 From: Daniel Townsend Date: Wed, 4 Oct 2023 22:31:44 +0100 Subject: [PATCH 5/6] update slotscheck --- requirements/dev-requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements/dev-requirements.txt b/requirements/dev-requirements.txt index cfd4560ca..2a72559a7 100644 --- a/requirements/dev-requirements.txt +++ b/requirements/dev-requirements.txt @@ -3,7 +3,7 @@ ipdb==0.13.9 ipython>=7.31.1 flake8==6.1.0 isort==5.10.1 -slotscheck==0.14.0 +slotscheck==0.17.0 twine==3.8.0 mypy==0.961 pip-upgrader==1.4.15 From b25c359e78d626c7329f1e8434c114648b4d151a Mon Sep 17 00:00:00 2001 From: Daniel Townsend Date: Fri, 3 Nov 2023 14:44:43 +0000 Subject: [PATCH 6/6] skip slotscheck for Python 3.12 for now --- scripts/lint.sh | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/scripts/lint.sh b/scripts/lint.sh index 14582f903..e328a6d8b 100755 --- a/scripts/lint.sh +++ b/scripts/lint.sh @@ -21,7 +21,15 @@ mypy $SOURCES echo "-----" echo "Running slotscheck..." -python -m slotscheck $MODULES +# Currently doesn't work for Python 3.12 - so skipping until we can get a proper fix. +pythonVersion=$(python -c 'import sys; print(f"{sys.version_info.major}.{sys.version_info.minor}")') +if [ "$pythonVersion" == '3.12' ] + then + echo "Skipping Python 3.12 for now" + else + python -m slotscheck $MODULES +fi + echo "-----" echo "All passed!"