From f00ed22404f9bd65804344dbdb5705d87badde5d Mon Sep 17 00:00:00 2001 From: Viraj Kanwade Date: Tue, 30 May 2023 14:26:18 -0700 Subject: [PATCH 01/10] =?UTF-8?q?=E2=AC=86=EF=B8=8F=20Upgrade=20minimum=20?= =?UTF-8?q?python=20version=203.8.1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../comment-docs-preview-in-pr/Dockerfile | 2 +- .github/actions/watch-previews/Dockerfile | 2 +- .github/workflows/build-docs.yml | 4 +-- .github/workflows/publish.yml | 4 +-- .github/workflows/test.yml | 7 ++-- README.md | 2 +- docs/contributing.md | 2 +- docs/features.md | 2 +- docs/index.md | 2 +- docs/tutorial/fastapi/tests.md | 2 +- docs/tutorial/index.md | 11 +++--- pyproject.toml | 30 ++++++++-------- scripts/lint.sh | 2 -- scripts/test.sh | 2 ++ sqlmodel/sql/expression.py | 35 +++++-------------- sqlmodel/sql/expression.py.jinja2 | 35 +++++-------------- 16 files changed, 52 insertions(+), 92 deletions(-) diff --git a/.github/actions/comment-docs-preview-in-pr/Dockerfile b/.github/actions/comment-docs-preview-in-pr/Dockerfile index 4f20c5f10b..d8d278432d 100644 --- a/.github/actions/comment-docs-preview-in-pr/Dockerfile +++ b/.github/actions/comment-docs-preview-in-pr/Dockerfile @@ -1,4 +1,4 @@ -FROM python:3.7 +FROM python:3.8 RUN pip install httpx "pydantic==1.5.1" pygithub diff --git a/.github/actions/watch-previews/Dockerfile b/.github/actions/watch-previews/Dockerfile index b8cc64d948..8d6dedc850 100644 --- a/.github/actions/watch-previews/Dockerfile +++ b/.github/actions/watch-previews/Dockerfile @@ -1,4 +1,4 @@ -FROM python:3.7 +FROM python:3.8 RUN pip install httpx PyGithub "pydantic==1.5.1" diff --git a/.github/workflows/build-docs.yml b/.github/workflows/build-docs.yml index 6400691533..8f6ff9fe86 100644 --- a/.github/workflows/build-docs.yml +++ b/.github/workflows/build-docs.yml @@ -8,7 +8,7 @@ on: workflow_dispatch: inputs: debug_enabled: - description: 'Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)' + description: 'Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)' required: false default: false jobs: @@ -23,7 +23,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v4 with: - python-version: "3.7" + python-version: "3.8.1" # Allow debugging with tmate - name: Setup tmate session uses: mxschmitt/action-tmate@v3 diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index f3c1e980a6..4af7efd813 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -7,7 +7,7 @@ on: workflow_dispatch: inputs: debug_enabled: - description: 'Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)' + description: 'Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)' required: false default: false @@ -19,7 +19,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v4 with: - python-version: "3.7" + python-version: "3.8.1" # Allow debugging with tmate - name: Setup tmate session uses: mxschmitt/action-tmate@v3 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 585ffc0455..43355a578c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -9,7 +9,7 @@ on: workflow_dispatch: inputs: debug_enabled: - description: 'Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)' + description: 'Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)' required: false default: false @@ -18,7 +18,7 @@ jobs: runs-on: ubuntu-20.04 strategy: matrix: - python-version: ["3.6.15", "3.7", "3.8", "3.9", "3.10"] + python-version: ["3.8.1", "3.9", "3.10", "3.11"] fail-fast: false steps: @@ -54,7 +54,6 @@ jobs: if: steps.cache.outputs.cache-hit != 'true' run: python -m poetry install - name: Lint - if: ${{ matrix.python-version != '3.6.15' }} run: python -m poetry run bash scripts/lint.sh - run: mkdir coverage - name: Test @@ -76,7 +75,7 @@ jobs: - uses: actions/setup-python@v4 with: - python-version: '3.8' + python-version: '3.8.1' - name: Get coverage files uses: actions/download-artifact@v3 diff --git a/README.md b/README.md index 5721f1cdb0..dce050053f 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,7 @@ It combines SQLAlchemy and Pydantic and tries to simplify the code you write as ## Requirements -A recent and currently supported version of Python (right now, Python supports versions 3.6 and above). +A recent and currently supported version of Python (right now, Python supports versions 3.8.1 and above). As **SQLModel** is based on **Pydantic** and **SQLAlchemy**, it requires them. They will be automatically installed when you install SQLModel. diff --git a/docs/contributing.md b/docs/contributing.md index f2964fba9b..075155cf9d 100644 --- a/docs/contributing.md +++ b/docs/contributing.md @@ -8,7 +8,7 @@ If you already cloned the repository and you know that you need to deep dive in ### Python -SQLModel supports Python 3.6 and above, but for development you should have at least **Python 3.7**. +SQLModel supports Python 3.8.1 and above. ### Poetry diff --git a/docs/features.md b/docs/features.md index 09de0c17f9..fecdad8992 100644 --- a/docs/features.md +++ b/docs/features.md @@ -12,7 +12,7 @@ Nevertheless, SQLModel is completely **independent** of FastAPI and can be used ## Just Modern Python -It's all based on standard modern **Python** type annotations. No new syntax to learn. Just standard modern Python. +It's all based on standard modern **Python** type annotations. No new syntax to learn. Just standard modern Python. If you need a 2 minute refresher of how to use Python types (even if you don't use SQLModel or FastAPI), check the FastAPI tutorial section: Python types intro. diff --git a/docs/index.md b/docs/index.md index 5721f1cdb0..dce050053f 100644 --- a/docs/index.md +++ b/docs/index.md @@ -50,7 +50,7 @@ It combines SQLAlchemy and Pydantic and tries to simplify the code you write as ## Requirements -A recent and currently supported version of Python (right now, Python supports versions 3.6 and above). +A recent and currently supported version of Python (right now, Python supports versions 3.8.1 and above). As **SQLModel** is based on **Pydantic** and **SQLAlchemy**, it requires them. They will be automatically installed when you install SQLModel. diff --git a/docs/tutorial/fastapi/tests.md b/docs/tutorial/fastapi/tests.md index f817a883a1..0aeac5c33f 100644 --- a/docs/tutorial/fastapi/tests.md +++ b/docs/tutorial/fastapi/tests.md @@ -389,7 +389,7 @@ Now we can run the tests with `pytest` and see the results: $ pytest ============= test session starts ============== -platform linux -- Python 3.7.5, pytest-6.2.4, py-1.10.0, pluggy-0.13.1 +platform linux -- Python 3.8.16, pytest-6.2.4, py-1.10.0, pluggy-0.13.1 rootdir: /home/user/code/sqlmodel-tutorial collected 7 items diff --git a/docs/tutorial/index.md b/docs/tutorial/index.md index 33cf6226c4..603dd35774 100644 --- a/docs/tutorial/index.md +++ b/docs/tutorial/index.md @@ -64,7 +64,7 @@ $ cd sqlmodel-tutorial Make sure you have an officially supported version of Python. -Currently it is **Python 3.6** and above (Python 3.5 was already deprecated). +Currently it is **Python 3.8.1** and above (Python 3.5 was already deprecated). You can check which version you have with: @@ -72,7 +72,7 @@ You can check which version you have with: ```console $ python3 --version -Python 3.6.9 +Python 3.8.16 ``` @@ -81,11 +81,10 @@ There's a chance that you have multiple Python versions installed. You might want to try with the specific versions, for example with: +* `python3.11` * `python3.10` * `python3.9` -* `python3.8` -* `python3.7` -* `python3.6` +* `python3.8.1` The code would look like this: @@ -136,7 +135,7 @@ Here are the commands you could use:
```console - // Remember that you might need to use python3.9 or similar 💡 + // Remember that you might need to use python3.9 or similar 💡 // Create the virtual environment using the module "venv" $ python3 -m venv env // ...here it creates the virtual enviroment in the directory "env" diff --git a/pyproject.toml b/pyproject.toml index e3b1d3c279..5e54664f2b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -17,10 +17,10 @@ classifiers = [ "Intended Audience :: System Administrators", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 3 :: Only", - "Programming Language :: Python :: 3.6", - "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", "Topic :: Database", "Topic :: Database :: Database Engines/Servers", "Topic :: Internet", @@ -30,7 +30,7 @@ classifiers = [ ] [tool.poetry.dependencies] -python = "^3.6.1" +python = "^3.8.1" SQLAlchemy = ">=1.4.17,<=1.4.41" pydantic = "^1.8.2" sqlalchemy2-stubs = {version = "*", allow-prereleases = true} @@ -39,19 +39,19 @@ sqlalchemy2-stubs = {version = "*", allow-prereleases = true} pytest = "^7.0.1" mypy = "0.971" flake8 = "^5.0.4" -black = {version = "^22.10.0", python = "^3.7"} +black = {version = "^22.10.0", python = "^3.8.1"} mkdocs = "^1.2.1" mkdocs-material = "^8.1.4" -pillow = {version = "^9.3.0", python = "^3.7"} -cairosvg = {version = "^2.5.2", python = "^3.7"} +pillow = {version = "^9.3.0", python = "^3.8.1"} +cairosvg = {version = "^2.5.2", python = "^3.8.1"} mdx-include = "^1.4.1" coverage = {extras = ["toml"], version = "^6.2"} fastapi = "^0.68.1" requests = "^2.26.0" autoflake = "^1.4" isort = "^5.9.3" -async_generator = {version = "*", python = "~3.6"} -async-exit-stack = {version = "*", python = "~3.6"} +async_generator = {version = "*", python = "~3.8.1"} +async-exit-stack = {version = "*", python = "~3.8.1"} [build-system] requires = ["poetry-core"] @@ -88,16 +88,16 @@ skip_glob = [ [tool.mypy] # --strict disallow_any_generics = true -disallow_subclassing_any = true -disallow_untyped_calls = true +disallow_subclassing_any = true +disallow_untyped_calls = true disallow_untyped_defs = true -disallow_incomplete_defs = true -check_untyped_defs = true -disallow_untyped_decorators = true +disallow_incomplete_defs = true +check_untyped_defs = true +disallow_untyped_decorators = true no_implicit_optional = true -warn_redundant_casts = true +warn_redundant_casts = true warn_unused_ignores = true -warn_return_any = true +warn_return_any = true implicit_reexport = false strict_equality = true # --strict end diff --git a/scripts/lint.sh b/scripts/lint.sh index 02568cda6b..4191d90f1f 100755 --- a/scripts/lint.sh +++ b/scripts/lint.sh @@ -7,5 +7,3 @@ mypy sqlmodel flake8 sqlmodel tests docs_src black sqlmodel tests docs_src --check isort sqlmodel tests docs_src scripts --check-only -# TODO: move this to test.sh after deprecating Python 3.6 -CHECK_JINJA=1 python scripts/generate_select.py diff --git a/scripts/test.sh b/scripts/test.sh index 9b758bdbdf..4fae64f046 100755 --- a/scripts/test.sh +++ b/scripts/test.sh @@ -3,6 +3,8 @@ set -e set -x +CHECK_JINJA=1 python scripts/generate_select.py + coverage run -m pytest tests coverage combine coverage report --show-missing diff --git a/sqlmodel/sql/expression.py b/sqlmodel/sql/expression.py index 31c0bc1a1e..ac77e85713 100644 --- a/sqlmodel/sql/expression.py +++ b/sqlmodel/sql/expression.py @@ -24,36 +24,17 @@ _TSelect = TypeVar("_TSelect") -# Workaround Generics incompatibility in Python 3.6 -# Ref: https://github.com/python/typing/issues/449#issuecomment-316061322 -if sys.version_info.minor >= 7: - class Select(_Select, Generic[_TSelect]): - inherit_cache = True +class Select(_Select, Generic[_TSelect]): + inherit_cache = True - # This is not comparable to sqlalchemy.sql.selectable.ScalarSelect, that has a different - # purpose. This is the same as a normal SQLAlchemy Select class where there's only one - # entity, so the result will be converted to a scalar by default. This way writing - # for loops on the results will feel natural. - class SelectOfScalar(_Select, Generic[_TSelect]): - inherit_cache = True -else: - from typing import GenericMeta # type: ignore - - class GenericSelectMeta(GenericMeta, _Select.__class__): # type: ignore - pass - - class _Py36Select(_Select, Generic[_TSelect], metaclass=GenericSelectMeta): - inherit_cache = True - - class _Py36SelectOfScalar(_Select, Generic[_TSelect], metaclass=GenericSelectMeta): - inherit_cache = True - - # Cast them for editors to work correctly, from several tricks tried, this works - # for both VS Code and PyCharm - Select = cast("Select", _Py36Select) # type: ignore - SelectOfScalar = cast("SelectOfScalar", _Py36SelectOfScalar) # type: ignore +# This is not comparable to sqlalchemy.sql.selectable.ScalarSelect, that has a different +# purpose. This is the same as a normal SQLAlchemy Select class where there's only one +# entity, so the result will be converted to a scalar by default. This way writing +# for loops on the results will feel natural. +class SelectOfScalar(_Select, Generic[_TSelect]): + inherit_cache = True if TYPE_CHECKING: # pragma: no cover diff --git a/sqlmodel/sql/expression.py.jinja2 b/sqlmodel/sql/expression.py.jinja2 index 51f04a215d..fcc52d7383 100644 --- a/sqlmodel/sql/expression.py.jinja2 +++ b/sqlmodel/sql/expression.py.jinja2 @@ -22,36 +22,17 @@ from sqlalchemy.sql.expression import Select as _Select _TSelect = TypeVar("_TSelect") -# Workaround Generics incompatibility in Python 3.6 -# Ref: https://github.com/python/typing/issues/449#issuecomment-316061322 -if sys.version_info.minor >= 7: - class Select(_Select, Generic[_TSelect]): - inherit_cache = True +class Select(_Select, Generic[_TSelect]): + inherit_cache = True - # This is not comparable to sqlalchemy.sql.selectable.ScalarSelect, that has a different - # purpose. This is the same as a normal SQLAlchemy Select class where there's only one - # entity, so the result will be converted to a scalar by default. This way writing - # for loops on the results will feel natural. - class SelectOfScalar(_Select, Generic[_TSelect]): - inherit_cache = True -else: - from typing import GenericMeta # type: ignore - - class GenericSelectMeta(GenericMeta, _Select.__class__): # type: ignore - pass - - class _Py36Select(_Select, Generic[_TSelect], metaclass=GenericSelectMeta): - inherit_cache = True - - class _Py36SelectOfScalar(_Select, Generic[_TSelect], metaclass=GenericSelectMeta): - inherit_cache = True - - # Cast them for editors to work correctly, from several tricks tried, this works - # for both VS Code and PyCharm - Select = cast("Select", _Py36Select) # type: ignore - SelectOfScalar = cast("SelectOfScalar", _Py36SelectOfScalar) # type: ignore +# This is not comparable to sqlalchemy.sql.selectable.ScalarSelect, that has a different +# purpose. This is the same as a normal SQLAlchemy Select class where there's only one +# entity, so the result will be converted to a scalar by default. This way writing +# for loops on the results will feel natural. +class SelectOfScalar(_Select, Generic[_TSelect]): + inherit_cache = True if TYPE_CHECKING: # pragma: no cover From 25a19251fb374846c2b1d4e36f949477870a8ce0 Mon Sep 17 00:00:00 2001 From: Viraj Kanwade Date: Tue, 30 May 2023 14:43:11 -0700 Subject: [PATCH 02/10] =?UTF-8?q?=E2=9C=8F=EF=B8=8F=20=20fix=20scripts/doc?= =?UTF-8?q?s-live.sh=20on=20PY=203.10+?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pyproject.toml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 5e54664f2b..6329f4b9ae 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -38,10 +38,10 @@ sqlalchemy2-stubs = {version = "*", allow-prereleases = true} [tool.poetry.dev-dependencies] pytest = "^7.0.1" mypy = "0.971" -flake8 = "^5.0.4" +flake8 = "^6.0.0" black = {version = "^22.10.0", python = "^3.8.1"} -mkdocs = "^1.2.1" -mkdocs-material = "^8.1.4" +mkdocs = "^1.4.3" +mkdocs-material = "^9.1.15" pillow = {version = "^9.3.0", python = "^3.8.1"} cairosvg = {version = "^2.5.2", python = "^3.8.1"} mdx-include = "^1.4.1" From a031c1365deb6d41796857b3e8d2d2078950ec6b Mon Sep 17 00:00:00 2001 From: Viraj Kanwade Date: Tue, 30 May 2023 14:49:09 -0700 Subject: [PATCH 03/10] =?UTF-8?q?=E2=9C=8F=EF=B8=8F=20=20Fix=20docs/contri?= =?UTF-8?q?buting.md=20to=20point=20to=20correct=20test=20script?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/contributing.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/contributing.md b/docs/contributing.md index 075155cf9d..fbf19076c2 100644 --- a/docs/contributing.md +++ b/docs/contributing.md @@ -116,7 +116,7 @@ There is a script that you can run locally to test all the code and generate cov
```console -$ bash scripts/test-cov-html.sh +$ bash scripts/test.sh ```
From beed72690cd6ff056f77138d01bbbc91523cfacd Mon Sep 17 00:00:00 2001 From: Viraj Kanwade Date: Tue, 30 May 2023 14:59:56 -0700 Subject: [PATCH 04/10] =?UTF-8?q?=E2=9C=8F=EF=B8=8F=20=20Fix=20scripts/lin?= =?UTF-8?q?t.sh=20for=20pydantic=20typing=20ForwardRef=20import?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pyproject.toml | 2 +- sqlmodel/main.py | 3 ++- sqlmodel/sql/expression.py | 2 -- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 6329f4b9ae..bae4e918ec 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -32,7 +32,7 @@ classifiers = [ [tool.poetry.dependencies] python = "^3.8.1" SQLAlchemy = ">=1.4.17,<=1.4.41" -pydantic = "^1.8.2" +pydantic = "^1.10.8" sqlalchemy2-stubs = {version = "*", allow-prereleases = true} [tool.poetry.dev-dependencies] diff --git a/sqlmodel/main.py b/sqlmodel/main.py index d95c498507..5b5950a811 100644 --- a/sqlmodel/main.py +++ b/sqlmodel/main.py @@ -11,6 +11,7 @@ Callable, ClassVar, Dict, + ForwardRef, List, Mapping, Optional, @@ -29,7 +30,7 @@ from pydantic.fields import FieldInfo as PydanticFieldInfo from pydantic.fields import ModelField, Undefined, UndefinedType from pydantic.main import ModelMetaclass, validate_model -from pydantic.typing import ForwardRef, NoArgAnyCallable, resolve_annotations +from pydantic.typing import NoArgAnyCallable, resolve_annotations from pydantic.utils import ROOT_KEY, Representation from sqlalchemy import Boolean, Column, Date, DateTime from sqlalchemy import Enum as sa_Enum diff --git a/sqlmodel/sql/expression.py b/sqlmodel/sql/expression.py index ac77e85713..264e39cba7 100644 --- a/sqlmodel/sql/expression.py +++ b/sqlmodel/sql/expression.py @@ -1,6 +1,5 @@ # WARNING: do not modify this code, it is generated by expression.py.jinja2 -import sys from datetime import datetime from typing import ( TYPE_CHECKING, @@ -12,7 +11,6 @@ Type, TypeVar, Union, - cast, overload, ) from uuid import UUID From d902223f0afd061ba5b608e937634c9bbd63ff4f Mon Sep 17 00:00:00 2001 From: Viraj Kanwade Date: Tue, 30 May 2023 20:49:40 -0700 Subject: [PATCH 05/10] =?UTF-8?q?=E2=AC=86=EF=B8=8F=20Upgrade=20dependenci?= =?UTF-8?q?es?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pyproject.toml | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index bae4e918ec..a45fed4ff0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -37,18 +37,19 @@ sqlalchemy2-stubs = {version = "*", allow-prereleases = true} [tool.poetry.dev-dependencies] pytest = "^7.0.1" -mypy = "0.971" +mypy = "1.3.0" flake8 = "^6.0.0" -black = {version = "^22.10.0", python = "^3.8.1"} +black = {version = "^23.3.0", python = "^3.8.1"} mkdocs = "^1.4.3" mkdocs-material = "^9.1.15" pillow = {version = "^9.3.0", python = "^3.8.1"} cairosvg = {version = "^2.5.2", python = "^3.8.1"} -mdx-include = "^1.4.1" -coverage = {extras = ["toml"], version = "^6.2"} -fastapi = "^0.68.1" +mdx-include = "^1.4.2" +coverage = {extras = ["toml"], version = "^7.2"} +fastapi = "^0.95.2" +httpx = "^0.23.0" requests = "^2.26.0" -autoflake = "^1.4" +autoflake = "^2.1.1" isort = "^5.9.3" async_generator = {version = "*", python = "~3.8.1"} async-exit-stack = {version = "*", python = "~3.8.1"} From d5f9dacc7a89f32d26777dfb3a10e189eb8b5cf0 Mon Sep 17 00:00:00 2001 From: Viraj Kanwade Date: Tue, 30 May 2023 21:17:59 -0700 Subject: [PATCH 06/10] =?UTF-8?q?=E2=9C=8F=EF=B8=8F=20=20Fix=20CHECK=5FJIN?= =?UTF-8?q?JA=3D1=20python=20scripts/generate=5Fselect.py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sqlmodel/sql/expression.py.jinja2 | 2 -- 1 file changed, 2 deletions(-) diff --git a/sqlmodel/sql/expression.py.jinja2 b/sqlmodel/sql/expression.py.jinja2 index fcc52d7383..80c2c5016e 100644 --- a/sqlmodel/sql/expression.py.jinja2 +++ b/sqlmodel/sql/expression.py.jinja2 @@ -1,4 +1,3 @@ -import sys from datetime import datetime from typing import ( TYPE_CHECKING, @@ -10,7 +9,6 @@ from typing import ( Type, TypeVar, Union, - cast, overload, ) from uuid import UUID From 23541374949283a59022e0492fbb844115351732 Mon Sep 17 00:00:00 2001 From: Viraj Kanwade Date: Tue, 30 May 2023 21:52:26 -0700 Subject: [PATCH 07/10] =?UTF-8?q?=E2=9C=8F=EF=B8=8F=20=20Fix=20pytests?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs_src/tutorial/fastapi/app_testing/tutorial001/main.py | 1 - docs_src/tutorial/fastapi/relationships/tutorial001.py | 1 - .../fastapi/session_with_dependency/tutorial001.py | 1 - docs_src/tutorial/fastapi/teams/tutorial001.py | 1 - sqlmodel/sql/sqltypes.py | 1 - .../test_fastapi/test_delete/test_tutorial001.py | 8 ++++++-- .../test_limit_and_offset/test_tutorial001.py | 3 +-- .../test_fastapi/test_multiple_models/test_tutorial001.py | 3 +-- .../test_fastapi/test_multiple_models/test_tutorial002.py | 3 +-- .../test_fastapi/test_read_one/test_tutorial001.py | 3 +-- .../test_fastapi/test_relationships/test_tutorial001.py | 2 +- .../test_fastapi/test_response_model/test_tutorial001.py | 3 +-- .../test_session_with_dependency/test_tutorial001.py | 3 +-- .../test_fastapi/test_simple_hero_api/test_tutorial001.py | 3 +-- .../test_fastapi/test_teams/test_tutorial001.py | 3 +-- .../test_fastapi/test_update/test_tutorial001.py | 3 +-- 16 files changed, 16 insertions(+), 26 deletions(-) diff --git a/docs_src/tutorial/fastapi/app_testing/tutorial001/main.py b/docs_src/tutorial/fastapi/app_testing/tutorial001/main.py index 88b8fbbcea..d106c4ebab 100644 --- a/docs_src/tutorial/fastapi/app_testing/tutorial001/main.py +++ b/docs_src/tutorial/fastapi/app_testing/tutorial001/main.py @@ -98,7 +98,6 @@ def update_hero( @app.delete("/heroes/{hero_id}") def delete_hero(*, session: Session = Depends(get_session), hero_id: int): - hero = session.get(Hero, hero_id) if not hero: raise HTTPException(status_code=404, detail="Hero not found") diff --git a/docs_src/tutorial/fastapi/relationships/tutorial001.py b/docs_src/tutorial/fastapi/relationships/tutorial001.py index 97220b95e5..6a03846686 100644 --- a/docs_src/tutorial/fastapi/relationships/tutorial001.py +++ b/docs_src/tutorial/fastapi/relationships/tutorial001.py @@ -136,7 +136,6 @@ def update_hero( @app.delete("/heroes/{hero_id}") def delete_hero(*, session: Session = Depends(get_session), hero_id: int): - hero = session.get(Hero, hero_id) if not hero: raise HTTPException(status_code=404, detail="Hero not found") diff --git a/docs_src/tutorial/fastapi/session_with_dependency/tutorial001.py b/docs_src/tutorial/fastapi/session_with_dependency/tutorial001.py index 88b8fbbcea..d106c4ebab 100644 --- a/docs_src/tutorial/fastapi/session_with_dependency/tutorial001.py +++ b/docs_src/tutorial/fastapi/session_with_dependency/tutorial001.py @@ -98,7 +98,6 @@ def update_hero( @app.delete("/heroes/{hero_id}") def delete_hero(*, session: Session = Depends(get_session), hero_id: int): - hero = session.get(Hero, hero_id) if not hero: raise HTTPException(status_code=404, detail="Hero not found") diff --git a/docs_src/tutorial/fastapi/teams/tutorial001.py b/docs_src/tutorial/fastapi/teams/tutorial001.py index 2a0bd600fc..6f84182bc9 100644 --- a/docs_src/tutorial/fastapi/teams/tutorial001.py +++ b/docs_src/tutorial/fastapi/teams/tutorial001.py @@ -127,7 +127,6 @@ def update_hero( @app.delete("/heroes/{hero_id}") def delete_hero(*, session: Session = Depends(get_session), hero_id: int): - hero = session.get(Hero, hero_id) if not hero: raise HTTPException(status_code=404, detail="Hero not found") diff --git a/sqlmodel/sql/sqltypes.py b/sqlmodel/sql/sqltypes.py index 09b8239476..17d9b06126 100644 --- a/sqlmodel/sql/sqltypes.py +++ b/sqlmodel/sql/sqltypes.py @@ -8,7 +8,6 @@ class AutoString(types.TypeDecorator): # type: ignore - impl = types.String cache_ok = True mysql_default_length = 255 diff --git a/tests/test_tutorial/test_fastapi/test_delete/test_tutorial001.py b/tests/test_tutorial/test_fastapi/test_delete/test_tutorial001.py index e560d04c0e..a89ac09479 100644 --- a/tests/test_tutorial/test_fastapi/test_delete/test_tutorial001.py +++ b/tests/test_tutorial/test_fastapi/test_delete/test_tutorial001.py @@ -241,7 +241,7 @@ "loc": { "title": "Location", "type": "array", - "items": {"type": "string"}, + "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]}, }, "msg": {"title": "Message", "type": "string"}, "type": {"title": "Error Type", "type": "string"}, @@ -261,7 +261,6 @@ def test_tutorial(clear_sqlmodel): ) with TestClient(mod.app) as client: - hero1_data = {"name": "Deadpond", "secret_name": "Dive Wilson"} hero2_data = { "name": "Spider-Boy", @@ -288,6 +287,11 @@ def test_tutorial(clear_sqlmodel): response = client.get("/openapi.json") data = response.json() assert response.status_code == 200, response.text + print("-" * 50) + print(data) + print("=" * 50) + print(openapi_schema) + print("*" * 50) assert data == openapi_schema response = client.get("/heroes/") assert response.status_code == 200, response.text diff --git a/tests/test_tutorial/test_fastapi/test_limit_and_offset/test_tutorial001.py b/tests/test_tutorial/test_fastapi/test_limit_and_offset/test_tutorial001.py index b58afdf683..08f0d1fa42 100644 --- a/tests/test_tutorial/test_fastapi/test_limit_and_offset/test_tutorial001.py +++ b/tests/test_tutorial/test_fastapi/test_limit_and_offset/test_tutorial001.py @@ -164,7 +164,7 @@ "loc": { "title": "Location", "type": "array", - "items": {"type": "string"}, + "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]}, }, "msg": {"title": "Message", "type": "string"}, "type": {"title": "Error Type", "type": "string"}, @@ -184,7 +184,6 @@ def test_tutorial(clear_sqlmodel): ) with TestClient(mod.app) as client: - hero1_data = {"name": "Deadpond", "secret_name": "Dive Wilson"} hero2_data = { "name": "Spider-Boy", diff --git a/tests/test_tutorial/test_fastapi/test_multiple_models/test_tutorial001.py b/tests/test_tutorial/test_fastapi/test_multiple_models/test_tutorial001.py index cf008563f4..8c44f48ddb 100644 --- a/tests/test_tutorial/test_fastapi/test_multiple_models/test_tutorial001.py +++ b/tests/test_tutorial/test_fastapi/test_multiple_models/test_tutorial001.py @@ -103,7 +103,7 @@ "loc": { "title": "Location", "type": "array", - "items": {"type": "string"}, + "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]}, }, "msg": {"title": "Message", "type": "string"}, "type": {"title": "Error Type", "type": "string"}, @@ -123,7 +123,6 @@ def test_tutorial(clear_sqlmodel): ) with TestClient(mod.app) as client: - hero1_data = {"name": "Deadpond", "secret_name": "Dive Wilson"} hero2_data = { "name": "Spider-Boy", diff --git a/tests/test_tutorial/test_fastapi/test_multiple_models/test_tutorial002.py b/tests/test_tutorial/test_fastapi/test_multiple_models/test_tutorial002.py index 57393a7ddc..710c5682b6 100644 --- a/tests/test_tutorial/test_fastapi/test_multiple_models/test_tutorial002.py +++ b/tests/test_tutorial/test_fastapi/test_multiple_models/test_tutorial002.py @@ -103,7 +103,7 @@ "loc": { "title": "Location", "type": "array", - "items": {"type": "string"}, + "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]}, }, "msg": {"title": "Message", "type": "string"}, "type": {"title": "Error Type", "type": "string"}, @@ -123,7 +123,6 @@ def test_tutorial(clear_sqlmodel): ) with TestClient(mod.app) as client: - hero1_data = {"name": "Deadpond", "secret_name": "Dive Wilson"} hero2_data = { "name": "Spider-Boy", diff --git a/tests/test_tutorial/test_fastapi/test_read_one/test_tutorial001.py b/tests/test_tutorial/test_fastapi/test_read_one/test_tutorial001.py index 5b3c771bb9..aaef3db30a 100644 --- a/tests/test_tutorial/test_fastapi/test_read_one/test_tutorial001.py +++ b/tests/test_tutorial/test_fastapi/test_read_one/test_tutorial001.py @@ -135,7 +135,7 @@ "loc": { "title": "Location", "type": "array", - "items": {"type": "string"}, + "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]}, }, "msg": {"title": "Message", "type": "string"}, "type": {"title": "Error Type", "type": "string"}, @@ -155,7 +155,6 @@ def test_tutorial(clear_sqlmodel): ) with TestClient(mod.app) as client: - hero1_data = {"name": "Deadpond", "secret_name": "Dive Wilson"} hero2_data = { "name": "Spider-Boy", diff --git a/tests/test_tutorial/test_fastapi/test_relationships/test_tutorial001.py b/tests/test_tutorial/test_fastapi/test_relationships/test_tutorial001.py index 125e00179c..e631660e13 100644 --- a/tests/test_tutorial/test_fastapi/test_relationships/test_tutorial001.py +++ b/tests/test_tutorial/test_fastapi/test_relationships/test_tutorial001.py @@ -488,7 +488,7 @@ "loc": { "title": "Location", "type": "array", - "items": {"type": "string"}, + "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]}, }, "msg": {"title": "Message", "type": "string"}, "type": {"title": "Error Type", "type": "string"}, diff --git a/tests/test_tutorial/test_fastapi/test_response_model/test_tutorial001.py b/tests/test_tutorial/test_fastapi/test_response_model/test_tutorial001.py index 54fbbdccad..6df4edfa93 100644 --- a/tests/test_tutorial/test_fastapi/test_response_model/test_tutorial001.py +++ b/tests/test_tutorial/test_fastapi/test_response_model/test_tutorial001.py @@ -91,7 +91,7 @@ "loc": { "title": "Location", "type": "array", - "items": {"type": "string"}, + "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]}, }, "msg": {"title": "Message", "type": "string"}, "type": {"title": "Error Type", "type": "string"}, @@ -111,7 +111,6 @@ def test_tutorial(clear_sqlmodel): ) with TestClient(mod.app) as client: - hero_data = {"name": "Deadpond", "secret_name": "Dive Wilson"} response = client.post("/heroes/", json=hero_data) data = response.json() diff --git a/tests/test_tutorial/test_fastapi/test_session_with_dependency/test_tutorial001.py b/tests/test_tutorial/test_fastapi/test_session_with_dependency/test_tutorial001.py index d8dbe3f7fb..628a14f220 100644 --- a/tests/test_tutorial/test_fastapi/test_session_with_dependency/test_tutorial001.py +++ b/tests/test_tutorial/test_fastapi/test_session_with_dependency/test_tutorial001.py @@ -241,7 +241,7 @@ "loc": { "title": "Location", "type": "array", - "items": {"type": "string"}, + "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]}, }, "msg": {"title": "Message", "type": "string"}, "type": {"title": "Error Type", "type": "string"}, @@ -261,7 +261,6 @@ def test_tutorial(clear_sqlmodel): ) with TestClient(mod.app) as client: - hero1_data = {"name": "Deadpond", "secret_name": "Dive Wilson"} hero2_data = { "name": "Spider-Boy", diff --git a/tests/test_tutorial/test_fastapi/test_simple_hero_api/test_tutorial001.py b/tests/test_tutorial/test_fastapi/test_simple_hero_api/test_tutorial001.py index 2f87fafeff..99fe6a1d70 100644 --- a/tests/test_tutorial/test_fastapi/test_simple_hero_api/test_tutorial001.py +++ b/tests/test_tutorial/test_fastapi/test_simple_hero_api/test_tutorial001.py @@ -79,7 +79,7 @@ "loc": { "title": "Location", "type": "array", - "items": {"type": "string"}, + "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]}, }, "msg": {"title": "Message", "type": "string"}, "type": {"title": "Error Type", "type": "string"}, @@ -99,7 +99,6 @@ def test_tutorial(clear_sqlmodel): ) with TestClient(mod.app) as client: - hero1_data = {"name": "Deadpond", "secret_name": "Dive Wilson"} hero2_data = { "name": "Spider-Boy", diff --git a/tests/test_tutorial/test_fastapi/test_teams/test_tutorial001.py b/tests/test_tutorial/test_fastapi/test_teams/test_tutorial001.py index 6ac1cffc5e..0520cd8805 100644 --- a/tests/test_tutorial/test_fastapi/test_teams/test_tutorial001.py +++ b/tests/test_tutorial/test_fastapi/test_teams/test_tutorial001.py @@ -454,7 +454,7 @@ "loc": { "title": "Location", "type": "array", - "items": {"type": "string"}, + "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]}, }, "msg": {"title": "Message", "type": "string"}, "type": {"title": "Error Type", "type": "string"}, @@ -474,7 +474,6 @@ def test_tutorial(clear_sqlmodel): ) with TestClient(mod.app) as client: - hero1_data = {"name": "Deadpond", "secret_name": "Dive Wilson"} hero2_data = { "name": "Spider-Boy", diff --git a/tests/test_tutorial/test_fastapi/test_update/test_tutorial001.py b/tests/test_tutorial/test_fastapi/test_update/test_tutorial001.py index e622fd37fb..54e95aa5de 100644 --- a/tests/test_tutorial/test_fastapi/test_update/test_tutorial001.py +++ b/tests/test_tutorial/test_fastapi/test_update/test_tutorial001.py @@ -213,7 +213,7 @@ "loc": { "title": "Location", "type": "array", - "items": {"type": "string"}, + "items": {"anyOf": [{"type": "string"}, {"type": "integer"}]}, }, "msg": {"title": "Message", "type": "string"}, "type": {"title": "Error Type", "type": "string"}, @@ -233,7 +233,6 @@ def test_tutorial(clear_sqlmodel): ) with TestClient(mod.app) as client: - hero1_data = {"name": "Deadpond", "secret_name": "Dive Wilson"} hero2_data = { "name": "Spider-Boy", From d9565f687d3cdf54252e846b3cea570401d62240 Mon Sep 17 00:00:00 2001 From: Viraj Kanwade Date: Wed, 31 May 2023 07:33:01 -0700 Subject: [PATCH 08/10] =?UTF-8?q?=E2=AC=86=EF=B8=8F=20Upgrade=20poetry=20v?= =?UTF-8?q?ersion?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build-docs.yml | 3 +-- .github/workflows/publish.yml | 3 +-- .github/workflows/test.yml | 3 +-- pyproject.toml | 2 +- 4 files changed, 4 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build-docs.yml b/.github/workflows/build-docs.yml index 8f6ff9fe86..43d96df795 100644 --- a/.github/workflows/build-docs.yml +++ b/.github/workflows/build-docs.yml @@ -42,8 +42,7 @@ jobs: # Ref: https://github.com/python-poetry/poetry-core/pull/188 run: | python -m pip install --upgrade pip - python -m pip install --force git+https://github.com/python-poetry/poetry-core.git@ad33bc2 - python -m pip install "poetry==1.2.0a2" + python -m pip install "poetry==1.5.1" python -m poetry plugin add poetry-version-plugin - name: Configure poetry run: python -m poetry config virtualenvs.create false diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 4af7efd813..0a998bdfb5 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -38,8 +38,7 @@ jobs: # Ref: https://github.com/python-poetry/poetry-core/pull/188 run: | python -m pip install --upgrade pip - python -m pip install --force git+https://github.com/python-poetry/poetry-core.git@ad33bc2 - python -m pip install "poetry==1.2.0a2" + python -m pip install "poetry==1.5.1" python -m poetry plugin add poetry-version-plugin - name: Configure poetry run: python -m poetry config virtualenvs.create false diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 43355a578c..68983c9bd8 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -45,8 +45,7 @@ jobs: # Ref: https://github.com/python-poetry/poetry-core/pull/188 run: | python -m pip install --upgrade pip - python -m pip install --force git+https://github.com/python-poetry/poetry-core.git@ad33bc2 - python -m pip install "poetry==1.2.0a2" + python -m pip install "poetry==1.5.1" python -m poetry plugin add poetry-version-plugin - name: Configure poetry run: python -m poetry config virtualenvs.create false diff --git a/pyproject.toml b/pyproject.toml index a45fed4ff0..1a31c5a8a3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -47,7 +47,7 @@ cairosvg = {version = "^2.5.2", python = "^3.8.1"} mdx-include = "^1.4.2" coverage = {extras = ["toml"], version = "^7.2"} fastapi = "^0.95.2" -httpx = "^0.23.0" +httpx = "^0.24.0" requests = "^2.26.0" autoflake = "^2.1.1" isort = "^5.9.3" From ed8d9b079853eee1f47a794f637b28aa8918cf58 Mon Sep 17 00:00:00 2001 From: Viraj Kanwade Date: Wed, 31 May 2023 08:55:09 -0700 Subject: [PATCH 09/10] =?UTF-8?q?=E2=AC=86=EF=B8=8F=20Update=20poetry=20ve?= =?UTF-8?q?rsion?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build-docs.yml | 2 +- .github/workflows/publish.yml | 2 +- .github/workflows/test.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-docs.yml b/.github/workflows/build-docs.yml index 43d96df795..e3f88a6f56 100644 --- a/.github/workflows/build-docs.yml +++ b/.github/workflows/build-docs.yml @@ -43,7 +43,7 @@ jobs: run: | python -m pip install --upgrade pip python -m pip install "poetry==1.5.1" - python -m poetry plugin add poetry-version-plugin + python -m poetry self add poetry-version-plugin - name: Configure poetry run: python -m poetry config virtualenvs.create false - name: Install Dependencies diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 0a998bdfb5..bfd935c5cc 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -39,7 +39,7 @@ jobs: run: | python -m pip install --upgrade pip python -m pip install "poetry==1.5.1" - python -m poetry plugin add poetry-version-plugin + python -m poetry self add poetry-version-plugin - name: Configure poetry run: python -m poetry config virtualenvs.create false - name: Install Dependencies diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 68983c9bd8..aa09303b6a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -46,7 +46,7 @@ jobs: run: | python -m pip install --upgrade pip python -m pip install "poetry==1.5.1" - python -m poetry plugin add poetry-version-plugin + python -m poetry self add poetry-version-plugin - name: Configure poetry run: python -m poetry config virtualenvs.create false - name: Install Dependencies From 70a7f3718d82aabfe2a2cc82b04f20bce47415cc Mon Sep 17 00:00:00 2001 From: Viraj Kanwade Date: Wed, 31 May 2023 09:19:04 -0700 Subject: [PATCH 10/10] =?UTF-8?q?=E2=AC=87=EF=B8=8F=20=20Downgrade=20poetr?= =?UTF-8?q?y=20to=201.4.2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build-docs.yml | 2 +- .github/workflows/publish.yml | 2 +- .github/workflows/test.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-docs.yml b/.github/workflows/build-docs.yml index e3f88a6f56..8cffa375c2 100644 --- a/.github/workflows/build-docs.yml +++ b/.github/workflows/build-docs.yml @@ -42,7 +42,7 @@ jobs: # Ref: https://github.com/python-poetry/poetry-core/pull/188 run: | python -m pip install --upgrade pip - python -m pip install "poetry==1.5.1" + python -m pip install "poetry==1.4.2" python -m poetry self add poetry-version-plugin - name: Configure poetry run: python -m poetry config virtualenvs.create false diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index bfd935c5cc..1cde34455e 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -38,7 +38,7 @@ jobs: # Ref: https://github.com/python-poetry/poetry-core/pull/188 run: | python -m pip install --upgrade pip - python -m pip install "poetry==1.5.1" + python -m pip install "poetry==1.4.2" python -m poetry self add poetry-version-plugin - name: Configure poetry run: python -m poetry config virtualenvs.create false diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index aa09303b6a..a03f0d9ae5 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -45,7 +45,7 @@ jobs: # Ref: https://github.com/python-poetry/poetry-core/pull/188 run: | python -m pip install --upgrade pip - python -m pip install "poetry==1.5.1" + python -m pip install "poetry==1.4.2" python -m poetry self add poetry-version-plugin - name: Configure poetry run: python -m poetry config virtualenvs.create false