diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index ce613342..69bc72a7 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -14,7 +14,7 @@ jobs: - name: Setup Python uses: actions/setup-python@v1 with: - python-version: '3.8' + python-version: '3.9' architecture: 'x64' - uses: actions/cache@v1 diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index c6e638f3..aab2cff3 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -20,10 +20,10 @@ jobs: key: ${{ runner.os }}-pip-${{ hashFiles('**/poetry.lock') }} restore-keys: | ${{ runner.os }}-pip- - - name: Set up Python 3.8 + - name: Set up Python 3.9 uses: actions/setup-python@v1 with: - python-version: 3.8 + python-version: 3.9 - name: Build publish run: | python -m pip install poetry poetry-dynamic-versioning diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f643e2f7..cd4f8553 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -10,7 +10,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] + python-version: ["3.9", "3.10", "3.11", "3.12"] os: [ubuntu-latest, windows-latest, macos-latest] steps: diff --git a/README.md b/README.md index 956d3449..2d4c7d05 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ Options: --specify-tags Use along with --generate-routers to generate specific routers from given list of tags. -c, --custom-visitors PATH - A custom visitor that adds variables to the template. -d, --output-model-type Specify a Pydantic base model to use (see [datamodel-code-generator](https://github.com/koxudaxi/datamodel-code-generator); default is `pydantic.BaseModel`). - -p, --python-version Specify a Python version to target (default is `3.8`). + -p, --python-version Specify a Python version to target (default is `3.9`). --install-completion Install completion for the current shell. --show-completion Show completion for the current shell, to copy it or customize the installation. diff --git a/fastapi_code_generator/patches.py b/fastapi_code_generator/patches.py index 9f5f6654..f3f4dd37 100644 --- a/fastapi_code_generator/patches.py +++ b/fastapi_code_generator/patches.py @@ -1,7 +1,11 @@ +# todo: remove this file when the following PR is merged into datamodels-code-generator: +# +# https://github.com/koxudaxi/datamodel-code-generator/pull/2379 + import logging from itertools import groupby from pathlib import Path -from typing import NamedTuple +from typing import NamedTuple, Optional, Union from datamodel_code_generator.format import CodeFormatter from datamodel_code_generator.imports import IMPORT_ANNOTATIONS, Import, Imports @@ -31,17 +35,17 @@ def __alias_shadowed_imports( def _parse( # noqa: PLR0912, PLR0914, PLR0915 self: base.Parser, - with_import: bool | None = True, # noqa: FBT001, FBT002 - format_: bool | None = True, # noqa: FBT001, FBT002 - settings_path: Path | None = None, - ) -> str | dict[tuple[str, ...], base.Result]: + with_import: Optional[bool] = True, # noqa: FBT001, FBT002 + format_: Optional[bool] = True, # noqa: FBT001, FBT002 + settings_path: Optional[Path] = None, + ) -> Union[str, dict[tuple[str, ...], base.Result]]: self.parse_raw() if with_import: self.imports.append(IMPORT_ANNOTATIONS) if format_: - code_formatter: CodeFormatter | None = CodeFormatter( + code_formatter: Optional[CodeFormatter] = CodeFormatter( self.target_python_version, settings_path, self.wrap_string_literal, diff --git a/poetry.lock b/poetry.lock index 58b960fe..e8b87169 100644 --- a/poetry.lock +++ b/poetry.lock @@ -652,10 +652,7 @@ files = [ [package.dependencies] annotated-types = ">=0.4.0" pydantic-core = "2.20.1" -typing-extensions = [ - {version = ">=4.12.2", markers = "python_version >= \"3.13\""}, - {version = ">=4.6.1", markers = "python_version < \"3.13\""}, -] +typing-extensions = {version = ">=4.6.1", markers = "python_version < \"3.13\""} [package.extras] email = ["email-validator (>=2.0.0)"] @@ -1120,5 +1117,5 @@ files = [ [metadata] lock-version = "2.1" -python-versions = "^3.9.0" -content-hash = "d312fae363b433a0f2497be586a9db4f3a53a5f81cbf5969f0a8d51c1d9cab48" +python-versions = ">=3.9,<3.13" +content-hash = "4c877a8538b055a678c7b0389bbe91cb862a0ecbc41d8fbd843b43be7999b23d" diff --git a/pyproject.toml b/pyproject.toml index d567f743..d3726ecc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -13,7 +13,6 @@ classifiers = [ "Natural Language :: English", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", @@ -30,7 +29,7 @@ pattern = "^(?P\\d+\\.\\d+\\.\\d+)(-?((?P[a-zA-Z]+)\\.?(?P