Skip to content
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/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
16 changes: 10 additions & 6 deletions fastapi_code_generator/patches.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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,
Expand Down
9 changes: 3 additions & 6 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -30,7 +29,7 @@ pattern = "^(?P<base>\\d+\\.\\d+\\.\\d+)(-?((?P<stage>[a-zA-Z]+)\\.?(?P<revision
fastapi-codegen = "fastapi_code_generator.__main__:app"

[tool.poetry.dependencies]
python = "^3.9.0"
python = ">=3.9,<3.13"
typer = {extras = ["all"], version = ">=0.2.1,<0.13.0"}
datamodel-code-generator = {extras = ["http"], version = "0.28.5"}
stringcase = "^1.2.0"
Expand All @@ -45,7 +44,7 @@ typed-ast = [
#mkdocs = {version = "1.1.2", optional = true}
#mkdocs-material = {version = "5.2.3", optional = true}

[tool.poetry.dev-dependencies]
[tool.poetry.group.dev.dependencies]
pytest = "^8.2"
pytest-cov = "*"
pytest-mock = "*"
Expand All @@ -61,7 +60,7 @@ isort = "==5.13.2"
[tool.black]
line-length = 88
skip-string-normalization = true
target-version = ['py38']
target-version = ['py39']
exclude = '(tests/data|\.eggs|\.git|\.hg|\.mypy_cache|\.nox|\.tox|\.venv|_build|buck-out|build|dist|.*\/models\.py.*|.*\/models\/.*)'

[tool.isort]
Expand Down