Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add Python 3.12 support #888

Merged
merged 7 commits into from
Nov 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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`
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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'
2 changes: 1 addition & 1 deletion piccolo/apps/migrations/auto/schema_differ.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions piccolo/query/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion piccolo/querystring.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion piccolo/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
4 changes: 2 additions & 2 deletions requirements/dev-requirements.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down
10 changes: 9 additions & 1 deletion scripts/lint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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!"
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions tests/columns/m2m/test_m2m.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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:
Expand Down
Loading