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 42a82aa10..d71d78e7e 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/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) 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/requirements/dev-requirements.txt b/requirements/dev-requirements.txt index bd8a17e15..2a72559a7 100644 --- a/requirements/dev-requirements.txt +++ b/requirements/dev-requirements.txt @@ -1,9 +1,9 @@ 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 +slotscheck==0.17.0 twine==3.8.0 mypy==0.961 pip-upgrader==1.4.15 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!" 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", 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: