Skip to content

Commit bc59e66

Browse files
authored
Fixed optional types and unions (#8)
* fixe optional types and unions * poetry lock rerun * Python 3.8 removed * Python 3.13 removed
1 parent 86bd218 commit bc59e66

File tree

7 files changed

+21
-21
lines changed

7 files changed

+21
-21
lines changed

.github/workflows/docs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
- name: Setup Python
1515
uses: actions/setup-python@v1
1616
with:
17-
python-version: '3.8'
17+
python-version: '3.9'
1818
architecture: 'x64'
1919

2020
- uses: actions/cache@v1

.github/workflows/publish.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ jobs:
2020
key: ${{ runner.os }}-pip-${{ hashFiles('**/poetry.lock') }}
2121
restore-keys: |
2222
${{ runner.os }}-pip-
23-
- name: Set up Python 3.8
23+
- name: Set up Python 3.9
2424
uses: actions/setup-python@v1
2525
with:
26-
python-version: 3.8
26+
python-version: 3.9
2727
- name: Build publish
2828
run: |
2929
python -m pip install poetry poetry-dynamic-versioning

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
strategy:
1111
fail-fast: false
1212
matrix:
13-
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
13+
python-version: ["3.9", "3.10", "3.11", "3.12"]
1414
os: [ubuntu-latest, windows-latest, macos-latest]
1515

1616
steps:

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ Options:
4040
--specify-tags Use along with --generate-routers to generate specific routers from given list of tags.
4141
-c, --custom-visitors PATH - A custom visitor that adds variables to the template.
4242
-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`).
43-
-p, --python-version Specify a Python version to target (default is `3.8`).
43+
-p, --python-version Specify a Python version to target (default is `3.9`).
4444
--install-completion Install completion for the current shell.
4545
--show-completion Show completion for the current shell, to copy it
4646
or customize the installation.

fastapi_code_generator/patches.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1+
# todo: remove this file when the following PR is merged into datamodels-code-generator:
2+
#
3+
# https://github.com/koxudaxi/datamodel-code-generator/pull/2379
4+
15
import logging
26
from itertools import groupby
37
from pathlib import Path
4-
from typing import NamedTuple
8+
from typing import NamedTuple, Optional, Union
59

610
from datamodel_code_generator.format import CodeFormatter
711
from datamodel_code_generator.imports import IMPORT_ANNOTATIONS, Import, Imports
@@ -31,17 +35,17 @@ def __alias_shadowed_imports(
3135

3236
def _parse( # noqa: PLR0912, PLR0914, PLR0915
3337
self: base.Parser,
34-
with_import: bool | None = True, # noqa: FBT001, FBT002
35-
format_: bool | None = True, # noqa: FBT001, FBT002
36-
settings_path: Path | None = None,
37-
) -> str | dict[tuple[str, ...], base.Result]:
38+
with_import: Optional[bool] = True, # noqa: FBT001, FBT002
39+
format_: Optional[bool] = True, # noqa: FBT001, FBT002
40+
settings_path: Optional[Path] = None,
41+
) -> Union[str, dict[tuple[str, ...], base.Result]]:
3842
self.parse_raw()
3943

4044
if with_import:
4145
self.imports.append(IMPORT_ANNOTATIONS)
4246

4347
if format_:
44-
code_formatter: CodeFormatter | None = CodeFormatter(
48+
code_formatter: Optional[CodeFormatter] = CodeFormatter(
4549
self.target_python_version,
4650
settings_path,
4751
self.wrap_string_literal,

poetry.lock

Lines changed: 3 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ classifiers = [
1313
"Natural Language :: English",
1414
"License :: OSI Approved :: MIT License",
1515
"Programming Language :: Python :: 3",
16-
"Programming Language :: Python :: 3.8",
1716
"Programming Language :: Python :: 3.9",
1817
"Programming Language :: Python :: 3.10",
1918
"Programming Language :: Python :: 3.11",
@@ -30,7 +29,7 @@ pattern = "^(?P<base>\\d+\\.\\d+\\.\\d+)(-?((?P<stage>[a-zA-Z]+)\\.?(?P<revision
3029
fastapi-codegen = "fastapi_code_generator.__main__:app"
3130

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

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

6766
[tool.isort]

0 commit comments

Comments
 (0)