diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7e008a54e..d8695a9a6 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -10,7 +10,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"] + python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] os: [ubuntu-latest, windows-latest, macos-latest] isort-version: [4.3.21, 5.6.4] black-version: [22.1.0, default] diff --git a/README.md b/README.md index d7d77dfdd..59200cb8d 100644 --- a/README.md +++ b/README.md @@ -452,8 +452,8 @@ Model customization: --keep-model-order Keep generated models' order --reuse-model Reuse models on the field when a module has the model with the same content - --target-python-version {3.6,3.7,3.8,3.9,3.10,3.11} - target python version (default: 3.7) + --target-python-version {3.8,3.9,3.10,3.11} + target python version (default: 3.8) --use-schema-description Use schema description to populate class docstring --use-title-as-name use titles as class names of models diff --git a/datamodel_code_generator/__init__.py b/datamodel_code_generator/__init__.py index 0f29e2f1e..02f45268b 100644 --- a/datamodel_code_generator/__init__.py +++ b/datamodel_code_generator/__init__.py @@ -241,7 +241,7 @@ def generate( input_file_type: InputFileType = InputFileType.Auto, output: Optional[Path] = None, output_model_type: DataModelType = DataModelType.PydanticBaseModel, - target_python_version: PythonVersion = PythonVersion.PY_37, + target_python_version: PythonVersion = PythonVersion.PY_38, base_class: str = '', additional_imports: Optional[List[str]] = None, custom_template_dir: Optional[Path] = None, diff --git a/datamodel_code_generator/__main__.py b/datamodel_code_generator/__main__.py index 7bb4b1ea2..9407c2f3c 100644 --- a/datamodel_code_generator/__main__.py +++ b/datamodel_code_generator/__main__.py @@ -153,13 +153,6 @@ def validate_url(cls, value: Any) -> Optional[ParseResult]: def validate_use_generic_container_types( cls, values: Dict[str, Any] ) -> Dict[str, Any]: - if values.get('use_generic_container_types'): - target_python_version: PythonVersion = values['target_python_version'] - if target_python_version == target_python_version.PY_36: - raise Error( - f'`--use-generic-container-types` can not be used with `--target-python_version` {target_python_version.PY_36.value}.\n' - ' The version will be not supported in a future version' - ) return values @model_validator(mode='after') @@ -252,7 +245,7 @@ def validate_root(cls, values: Any) -> Any: output: Optional[Path] = None debug: bool = False disable_warnings: bool = False - target_python_version: PythonVersion = PythonVersion.PY_37 + target_python_version: PythonVersion = PythonVersion.PY_38 base_class: str = '' additional_imports: Optional[List[str]] = (None,) custom_template_dir: Optional[Path] = None diff --git a/datamodel_code_generator/format.py b/datamodel_code_generator/format.py index 88219057b..18d4ddacd 100644 --- a/datamodel_code_generator/format.py +++ b/datamodel_code_generator/format.py @@ -1,6 +1,7 @@ from __future__ import annotations from enum import Enum +from functools import cached_property from importlib import import_module from pathlib import Path from typing import TYPE_CHECKING, Any, Dict, List, Optional, Sequence @@ -9,7 +10,7 @@ import black import isort -from datamodel_code_generator.util import cached_property, load_toml +from datamodel_code_generator.util import load_toml try: import black.mode @@ -18,8 +19,6 @@ class PythonVersion(Enum): - PY_36 = '3.6' - PY_37 = '3.7' PY_38 = '3.8' PY_39 = '3.9' PY_310 = '3.10' @@ -28,17 +27,15 @@ class PythonVersion(Enum): @cached_property def _is_py_38_or_later(self) -> bool: # pragma: no cover - return self.value not in {self.PY_36.value, self.PY_37.value} # type: ignore + return True # type: ignore @cached_property def _is_py_39_or_later(self) -> bool: # pragma: no cover - return self.value not in {self.PY_36.value, self.PY_37.value, self.PY_38.value} # type: ignore + return self.value not in {self.PY_38.value} # type: ignore @cached_property def _is_py_310_or_later(self) -> bool: # pragma: no cover return self.value not in { - self.PY_36.value, - self.PY_37.value, self.PY_38.value, self.PY_39.value, } # type: ignore @@ -46,8 +43,6 @@ def _is_py_310_or_later(self) -> bool: # pragma: no cover @cached_property def _is_py_311_or_later(self) -> bool: # pragma: no cover return self.value not in { - self.PY_36.value, - self.PY_37.value, self.PY_38.value, self.PY_39.value, self.PY_310.value, diff --git a/datamodel_code_generator/imports.py b/datamodel_code_generator/imports.py index 0b4564dba..6e39efcaf 100644 --- a/datamodel_code_generator/imports.py +++ b/datamodel_code_generator/imports.py @@ -14,7 +14,7 @@ class Import(BaseModel): reference_path: Optional[str] = None @classmethod - @lru_cache() + @lru_cache def from_full_path(cls, class_path: str) -> Import: split_class_path: List[str] = class_path.split('.') return Import( diff --git a/datamodel_code_generator/model/base.py b/datamodel_code_generator/model/base.py index de62a9628..2b82f4637 100644 --- a/datamodel_code_generator/model/base.py +++ b/datamodel_code_generator/model/base.py @@ -1,6 +1,6 @@ from abc import ABC, abstractmethod from collections import defaultdict -from functools import lru_cache +from functools import cached_property, lru_cache from pathlib import Path from typing import ( TYPE_CHECKING, @@ -39,7 +39,7 @@ chain_as_tuple, get_optional_type, ) -from datamodel_code_generator.util import PYDANTIC_V2, ConfigDict, cached_property +from datamodel_code_generator.util import PYDANTIC_V2, ConfigDict TEMPLATE_DIR: Path = Path(__file__).parents[0] / 'template' @@ -225,7 +225,7 @@ def fall_back_to_nullable(self) -> bool: return True -@lru_cache() +@lru_cache def get_template(template_file_path: Path) -> Template: loader = FileSystemLoader(str(TEMPLATE_DIR / template_file_path.parent)) environment: Environment = Environment(loader=loader) diff --git a/datamodel_code_generator/model/pydantic/base_model.py b/datamodel_code_generator/model/pydantic/base_model.py index 3c50fcb92..6932a83d1 100644 --- a/datamodel_code_generator/model/pydantic/base_model.py +++ b/datamodel_code_generator/model/pydantic/base_model.py @@ -1,4 +1,5 @@ from abc import ABC +from functools import cached_property from pathlib import Path from typing import Any, ClassVar, DefaultDict, Dict, List, Optional, Set, Tuple @@ -18,7 +19,6 @@ ) from datamodel_code_generator.reference import Reference from datamodel_code_generator.types import UnionIntFloat, chain_as_tuple -from datamodel_code_generator.util import cached_property class Constraints(ConstraintsBase): diff --git a/datamodel_code_generator/model/pydantic/types.py b/datamodel_code_generator/model/pydantic/types.py index 4f0e20982..459079f7f 100644 --- a/datamodel_code_generator/model/pydantic/types.py +++ b/datamodel_code_generator/model/pydantic/types.py @@ -151,7 +151,7 @@ class DataTypeManager(_DataTypeManager): def __init__( self, - python_version: PythonVersion = PythonVersion.PY_37, + python_version: PythonVersion = PythonVersion.PY_38, use_standard_collections: bool = False, use_generic_container_types: bool = False, strict_types: Optional[Sequence[StrictTypes]] = None, diff --git a/datamodel_code_generator/model/pydantic_v2/base_model.py b/datamodel_code_generator/model/pydantic_v2/base_model.py index b9d811476..572c868af 100644 --- a/datamodel_code_generator/model/pydantic_v2/base_model.py +++ b/datamodel_code_generator/model/pydantic_v2/base_model.py @@ -1,12 +1,12 @@ import re from pathlib import Path from typing import ( - TYPE_CHECKING, Any, ClassVar, DefaultDict, Dict, List, + Literal, NamedTuple, Optional, Set, @@ -28,14 +28,6 @@ from datamodel_code_generator.reference import Reference from datamodel_code_generator.util import field_validator, model_validator -if TYPE_CHECKING: - from typing_extensions import Literal -else: - try: - from typing import Literal - except ImportError: - from typing_extensions import Literal - class Constraints(_Constraints): # To override existing pattern alias diff --git a/datamodel_code_generator/model/pydantic_v2/root_model.py b/datamodel_code_generator/model/pydantic_v2/root_model.py index 2cf518874..c88e25083 100644 --- a/datamodel_code_generator/model/pydantic_v2/root_model.py +++ b/datamodel_code_generator/model/pydantic_v2/root_model.py @@ -1,12 +1,9 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Any, ClassVar, Optional +from typing import Any, ClassVar, Literal, Optional from datamodel_code_generator.model.pydantic_v2.base_model import BaseModel -if TYPE_CHECKING: - from typing_extensions import Literal - class RootModel(BaseModel): TEMPLATE_FILE_PATH: ClassVar[str] = 'pydantic_v2/RootModel.jinja2' diff --git a/datamodel_code_generator/model/types.py b/datamodel_code_generator/model/types.py index 2371e1f5d..6905f5f40 100644 --- a/datamodel_code_generator/model/types.py +++ b/datamodel_code_generator/model/types.py @@ -52,7 +52,7 @@ def type_map_factory( class DataTypeManager(_DataTypeManager): def __init__( self, - python_version: PythonVersion = PythonVersion.PY_37, + python_version: PythonVersion = PythonVersion.PY_38, use_standard_collections: bool = False, use_generic_container_types: bool = False, strict_types: Optional[Sequence[StrictTypes]] = None, diff --git a/datamodel_code_generator/parser/base.py b/datamodel_code_generator/parser/base.py index 878f01370..e34d3599c 100644 --- a/datamodel_code_generator/parser/base.py +++ b/datamodel_code_generator/parser/base.py @@ -15,12 +15,14 @@ Mapping, NamedTuple, Optional, + Protocol, Sequence, Set, Tuple, Type, TypeVar, Union, + runtime_checkable, ) from urllib.parse import ParseResult @@ -48,7 +50,6 @@ from datamodel_code_generator.parser import DefaultPutDict, LiteralType from datamodel_code_generator.reference import ModelResolver, Reference from datamodel_code_generator.types import DataType, DataTypeManager, StrictTypes -from datamodel_code_generator.util import Protocol, runtime_checkable SPECIAL_PATH_FORMAT: str = '#-datamodel-code-generator-#-{}-#-special-#' @@ -342,7 +343,7 @@ def __init__( additional_imports: Optional[List[str]] = None, custom_template_dir: Optional[Path] = None, extra_template_data: Optional[DefaultDict[str, Dict[str, Any]]] = None, - target_python_version: PythonVersion = PythonVersion.PY_37, + target_python_version: PythonVersion = PythonVersion.PY_38, dump_resolve_reference_action: Optional[Callable[[Iterable[str]], str]] = None, validation: bool = False, field_constraints: bool = False, @@ -1228,8 +1229,7 @@ def parse( self.parse_raw() if with_import: - if self.target_python_version != PythonVersion.PY_36: - self.imports.append(IMPORT_ANNOTATIONS) + self.imports.append(IMPORT_ANNOTATIONS) if format_: code_formatter: Optional[CodeFormatter] = CodeFormatter( diff --git a/datamodel_code_generator/parser/graphql.py b/datamodel_code_generator/parser/graphql.py index 9eb55d6c8..a71165785 100644 --- a/datamodel_code_generator/parser/graphql.py +++ b/datamodel_code_generator/parser/graphql.py @@ -102,7 +102,7 @@ def __init__( additional_imports: Optional[List[str]] = None, custom_template_dir: Optional[Path] = None, extra_template_data: Optional[DefaultDict[str, Dict[str, Any]]] = None, - target_python_version: PythonVersion = PythonVersion.PY_37, + target_python_version: PythonVersion = PythonVersion.PY_38, dump_resolve_reference_action: Optional[Callable[[Iterable[str]], str]] = None, validation: bool = False, field_constraints: bool = False, diff --git a/datamodel_code_generator/parser/jsonschema.py b/datamodel_code_generator/parser/jsonschema.py index c849ad3c6..2e772b30e 100644 --- a/datamodel_code_generator/parser/jsonschema.py +++ b/datamodel_code_generator/parser/jsonschema.py @@ -3,7 +3,7 @@ import enum as _enum from collections import defaultdict from contextlib import contextmanager -from functools import lru_cache +from functools import cached_property, lru_cache from pathlib import Path from typing import ( TYPE_CHECKING, @@ -63,7 +63,6 @@ from datamodel_code_generator.util import ( PYDANTIC_V2, BaseModel, - cached_property, field_validator, model_validator, ) @@ -317,7 +316,7 @@ def type_has_null(self) -> bool: return isinstance(self.type, list) and 'null' in self.type -@lru_cache() +@lru_cache def get_ref_type(ref: str) -> JSONReference: if ref[0] == '#': return JSONReference.LOCAL @@ -384,7 +383,7 @@ def __init__( additional_imports: Optional[List[str]] = None, custom_template_dir: Optional[Path] = None, extra_template_data: Optional[DefaultDict[str, Dict[str, Any]]] = None, - target_python_version: PythonVersion = PythonVersion.PY_37, + target_python_version: PythonVersion = PythonVersion.PY_38, dump_resolve_reference_action: Optional[Callable[[Iterable[str]], str]] = None, validation: bool = False, field_constraints: bool = False, diff --git a/datamodel_code_generator/parser/openapi.py b/datamodel_code_generator/parser/openapi.py index 89ad80314..fd52de87b 100644 --- a/datamodel_code_generator/parser/openapi.py +++ b/datamodel_code_generator/parser/openapi.py @@ -165,7 +165,7 @@ def __init__( additional_imports: Optional[List[str]] = None, custom_template_dir: Optional[Path] = None, extra_template_data: Optional[DefaultDict[str, Dict[str, Any]]] = None, - target_python_version: PythonVersion = PythonVersion.PY_37, + target_python_version: PythonVersion = PythonVersion.PY_38, dump_resolve_reference_action: Optional[Callable[[Iterable[str]], str]] = None, validation: bool = False, field_constraints: bool = False, diff --git a/datamodel_code_generator/reference.py b/datamodel_code_generator/reference.py index 677e3fe1b..2f10259dc 100644 --- a/datamodel_code_generator/reference.py +++ b/datamodel_code_generator/reference.py @@ -2,7 +2,7 @@ from collections import defaultdict from contextlib import contextmanager from enum import Enum, auto -from functools import lru_cache +from functools import cached_property, lru_cache from itertools import zip_longest from keyword import iskeyword from pathlib import Path, PurePath @@ -37,7 +37,6 @@ from datamodel_code_generator.util import ( PYDANTIC_V2, ConfigDict, - cached_property, model_validator, ) @@ -182,7 +181,7 @@ def context_variable( _UNDER_SCORE_2: Pattern[str] = re.compile('([a-z0-9])([A-Z])') -@lru_cache() +@lru_cache def camel_to_snake(string: str) -> str: subbed = _UNDER_SCORE_1.sub(r'\1_\2', string) return _UNDER_SCORE_2.sub(r'\1_\2', subbed).lower() @@ -741,7 +740,7 @@ def get_valid_field_name_and_alias( ) -@lru_cache() +@lru_cache def get_singular_name(name: str, suffix: str = SINGULAR_NAME_SUFFIX) -> str: singular_name = inflect_engine.singular_noun(name) if singular_name is False: @@ -749,7 +748,7 @@ def get_singular_name(name: str, suffix: str = SINGULAR_NAME_SUFFIX) -> str: return singular_name -@lru_cache() +@lru_cache def snake_to_upper_camel(word: str, delimiter: str = '_') -> str: prefix = '' if word.startswith(delimiter): diff --git a/datamodel_code_generator/types.py b/datamodel_code_generator/types.py index fc7294882..afa264a5e 100644 --- a/datamodel_code_generator/types.py +++ b/datamodel_code_generator/types.py @@ -15,12 +15,14 @@ List, Optional, Pattern, + Protocol, Sequence, Set, Tuple, Type, TypeVar, Union, + runtime_checkable, ) import pydantic @@ -53,8 +55,6 @@ from datamodel_code_generator.util import ( PYDANTIC_V2, ConfigDict, - Protocol, - runtime_checkable, ) if PYDANTIC_V2: @@ -166,7 +166,7 @@ def chain_as_tuple(*iterables: Iterable[T]) -> Tuple[T, ...]: return tuple(chain(*iterables)) -@lru_cache() +@lru_cache def _remove_none_from_type( type_: str, split_pattern: Pattern[str], delimiter: str ) -> List[str]: @@ -212,7 +212,7 @@ def _remove_none_from_union(type_: str, use_union_operator: bool) -> str: return f'{UNION_PREFIX}{UNION_DELIMITER.join(inner_types)}]' -@lru_cache() +@lru_cache def get_optional_type(type_: str, use_union_operator: bool) -> str: type_ = _remove_none_from_union(type_, use_union_operator) @@ -266,7 +266,7 @@ class Config: is_func: bool = False kwargs: Optional[Dict[str, Any]] = None import_: Optional[Import] = None - python_version: PythonVersion = PythonVersion.PY_37 + python_version: PythonVersion = PythonVersion.PY_38 is_optional: bool = False is_dict: bool = False is_list: bool = False @@ -480,8 +480,6 @@ def type_hint(self) -> str: source = self.reference.source if isinstance(source, Nullable) and source.nullable: self.is_optional = True - if self.reference and self.python_version == PythonVersion.PY_36: - type_ = f"'{type_}'" if self.is_list: if self.use_generic_container: list_ = SEQUENCE @@ -572,7 +570,7 @@ class Types(Enum): class DataTypeManager(ABC): def __init__( self, - python_version: PythonVersion = PythonVersion.PY_37, + python_version: PythonVersion = PythonVersion.PY_38, use_standard_collections: bool = False, use_generic_container_types: bool = False, strict_types: Optional[Sequence[StrictTypes]] = None, @@ -590,14 +588,6 @@ def __init__( self.use_union_operator: bool = use_union_operator self.use_pendulum: bool = use_pendulum - if ( - use_generic_container_types and python_version == PythonVersion.PY_36 - ): # pragma: no cover - raise Exception( - 'use_generic_container_types can not be used with target_python_version 3.6.\n' - ' The version will be not supported in a future version' - ) - if TYPE_CHECKING: self.data_type: Type[DataType] else: diff --git a/datamodel_code_generator/util.py b/datamodel_code_generator/util.py index b00b2231e..4a184bdee 100644 --- a/datamodel_code_generator/util.py +++ b/datamodel_code_generator/util.py @@ -2,7 +2,7 @@ import copy from pathlib import Path -from typing import TYPE_CHECKING, Any, Callable, Dict, TypeVar +from typing import TYPE_CHECKING, Any, Callable, Dict, Literal, TypeVar import pydantic from packaging import version @@ -15,7 +15,6 @@ PYDANTIC_V2: bool = PYDANTIC_VERSION >= version.parse('2.0b3') if TYPE_CHECKING: - cached_property = property from yaml import SafeLoader Protocol = object @@ -26,35 +25,11 @@ def load_toml(path: Path) -> Dict[str, Any]: ... else: - try: - from typing import Protocol - except ImportError: - from typing_extensions import Protocol # noqa - try: - from typing import runtime_checkable - except ImportError: - from typing_extensions import runtime_checkable # noqa try: from yaml import CSafeLoader as SafeLoader except ImportError: # pragma: no cover from yaml import SafeLoader - try: - from functools import cached_property - except ImportError: - _NOT_FOUND = object() - - class cached_property: - def __init__(self, func: Callable) -> None: - self.func: Callable = func - self.__doc__: Any = func.__doc__ - - def __get__(self, instance: Any, owner: Any = None) -> Any: - value = instance.__dict__.get(self.func.__name__, _NOT_FOUND) - if value is _NOT_FOUND: # pragma: no cover - value = instance.__dict__[self.func.__name__] = self.func(instance) - return value - try: import tomllib diff --git a/docs/index.md b/docs/index.md index 6291035b2..0184e972c 100644 --- a/docs/index.md +++ b/docs/index.md @@ -444,8 +444,8 @@ Model customization: --keep-model-order Keep generated models' order --reuse-model Reuse models on the field when a module has the model with the same content - --target-python-version {3.6,3.7,3.8,3.9,3.10,3.11} - target python version (default: 3.7) + --target-python-version {3.8,3.9,3.10,3.11} + target python version (default: 3.8) --use-schema-description Use schema description to populate class docstring --use-title-as-name use titles as class names of models diff --git a/docs/pyproject_toml.md b/docs/pyproject_toml.md index 383fab356..095f9b38b 100644 --- a/docs/pyproject_toml.md +++ b/docs/pyproject_toml.md @@ -8,5 +8,5 @@ Example `pyproject.toml`: field-constraints = true snake-case-field = true strip-default-none = false -target-python-version = "3.7" +target-python-version = "3.8" ``` diff --git a/poetry.lock b/poetry.lock index d3b2fd17d..6867144a6 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,4 +1,7 @@ -# This file is automatically @generated by Poetry 1.8.2 and should not be changed by hand. + + +[package.dependencies] +typing-extensions = {version = ">=4.0.0", markers = "python_version < \"3.9\""} [[package]] name = "anyio" @@ -15,7 +18,6 @@ files = [ exceptiongroup = {version = "*", markers = "python_version < \"3.11\""} idna = ">=2.8" sniffio = ">=1.1" -typing-extensions = {version = "*", markers = "python_version < \"3.8\""} [package.extras] doc = ["Sphinx", "packaging", "sphinx-autodoc-typehints (>=1.2.0)", "sphinx-rtd-theme (>=1.2.2)", "sphinxcontrib-jquery"] @@ -33,9 +35,6 @@ files = [ {file = "argcomplete-3.1.2.tar.gz", hash = "sha256:d5d1e5efd41435260b8f85673b74ea2e883affcbec9f4230c582689e8e78251b"}, ] -[package.dependencies] -importlib-metadata = {version = ">=0.23,<7", markers = "python_version < \"3.8\""} - [package.extras] test = ["coverage", "mypy", "pexpect", "ruff", "wheel"] @@ -102,7 +101,6 @@ packaging = ">=22.0" pathspec = ">=0.9.0" platformdirs = ">=2" tomli = {version = ">=1.1.0", markers = "python_version < \"3.11\""} -typed-ast = {version = ">=1.4.2", markers = "python_version < \"3.8\" and implementation_name == \"cpython\""} typing-extensions = {version = ">=3.10.0.0", markers = "python_version < \"3.10\""} [package.extras] @@ -357,7 +355,6 @@ files = [ [package.dependencies] colorama = {version = "*", markers = "platform_system == \"Windows\""} -importlib-metadata = {version = "*", markers = "python_version < \"3.8\""} [[package]] name = "colorama" @@ -456,26 +453,6 @@ files = [ {file = "distlib-0.3.8.tar.gz", hash = "sha256:1530ea13e350031b6312d8580ddb6b27a104275a31106523b8f123787f494f64"}, ] -[[package]] -name = "dnspython" -version = "2.3.0" -description = "DNS toolkit" -optional = false -python-versions = ">=3.7,<4.0" -files = [ - {file = "dnspython-2.3.0-py3-none-any.whl", hash = "sha256:89141536394f909066cabd112e3e1a37e4e654db00a25308b0f130bc3152eb46"}, - {file = "dnspython-2.3.0.tar.gz", hash = "sha256:224e32b03eb46be70e12ef6d64e0be123a64e621ab4c0822ff6d450d52a540b9"}, -] - -[package.extras] -curio = ["curio (>=1.2,<2.0)", "sniffio (>=1.1,<2.0)"] -dnssec = ["cryptography (>=2.6,<40.0)"] -doh = ["h2 (>=4.1.0)", "httpx (>=0.21.1)", "requests (>=2.23.0,<3.0.0)", "requests-toolbelt (>=0.9.1,<0.11.0)"] -doq = ["aioquic (>=0.9.20)"] -idna = ["idna (>=2.1,<4.0)"] -trio = ["trio (>=0.14,<0.23)"] -wmi = ["wmi (>=1.5.1,<2.0.0)"] - [[package]] name = "dnspython" version = "2.4.2" @@ -495,21 +472,6 @@ idna = ["idna (>=2.1,<4.0)"] trio = ["trio (>=0.14,<0.23)"] wmi = ["wmi (>=1.5.1,<2.0.0)"] -[[package]] -name = "email-validator" -version = "2.0.0.post2" -description = "A robust email address syntax and deliverability validation library." -optional = false -python-versions = ">=3.7" -files = [ - {file = "email_validator-2.0.0.post2-py3-none-any.whl", hash = "sha256:2466ba57cda361fb7309fd3d5a225723c788ca4bbad32a0ebd5373b99730285c"}, - {file = "email_validator-2.0.0.post2.tar.gz", hash = "sha256:1ff6e86044200c56ae23595695c54e9614f4a9551e0e393614f764860b3d7900"}, -] - -[package.dependencies] -dnspython = ">=2.0.0" -idna = ">=2.0.0" - [[package]] name = "email-validator" version = "2.1.0.post1" @@ -604,9 +566,6 @@ files = [ {file = "graphql_core-3.2.3-py3-none-any.whl", hash = "sha256:5766780452bd5ec8ba133f8bf287dc92713e3868ddd83aee4faab9fc3e303dc3"}, ] -[package.dependencies] -typing-extensions = {version = ">=4.2,<5", markers = "python_version < \"3.8\""} - [[package]] name = "h11" version = "0.14.0" @@ -618,9 +577,6 @@ files = [ {file = "h11-0.14.0.tar.gz", hash = "sha256:8f19fbbe99e72420ff35c00b27a34cb9937e902a8b810e2c88300c6f0a3b699d"}, ] -[package.dependencies] -typing-extensions = {version = "*", markers = "python_version < \"3.8\""} - [[package]] name = "httpcore" version = "0.17.3" @@ -690,44 +646,6 @@ files = [ {file = "idna-3.7.tar.gz", hash = "sha256:028ff3aadf0609c1fd278d8ea3089299412a7a8b9bd005dd08b9f8285bcb5cfc"}, ] -[[package]] -name = "importlib-metadata" -version = "6.7.0" -description = "Read metadata from Python packages" -optional = false -python-versions = ">=3.7" -files = [ - {file = "importlib_metadata-6.7.0-py3-none-any.whl", hash = "sha256:cb52082e659e97afc5dac71e79de97d8681de3aa07ff18578330904a9d18e5b5"}, - {file = "importlib_metadata-6.7.0.tar.gz", hash = "sha256:1aaf550d4f73e5d6783e7acb77aec43d49da8017410afae93822cc9cca98c4d4"}, -] - -[package.dependencies] -typing-extensions = {version = ">=3.6.4", markers = "python_version < \"3.8\""} -zipp = ">=0.5" - -[package.extras] -docs = ["furo", "jaraco.packaging (>=9)", "jaraco.tidelift (>=1.4)", "rst.linker (>=1.9)", "sphinx (>=3.5)", "sphinx-lint"] -perf = ["ipython"] -testing = ["flufl.flake8", "importlib-resources (>=1.3)", "packaging", "pyfakefs", "pytest (>=6)", "pytest-black (>=0.3.7)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=1.3)", "pytest-mypy (>=0.9.1)", "pytest-perf (>=0.9.2)", "pytest-ruff"] - -[[package]] -name = "importlib-resources" -version = "5.12.0" -description = "Read resources from Python packages" -optional = false -python-versions = ">=3.7" -files = [ - {file = "importlib_resources-5.12.0-py3-none-any.whl", hash = "sha256:7b1deeebbf351c7578e09bf2f63fa2ce8b5ffec296e0d349139d43cca061a81a"}, - {file = "importlib_resources-5.12.0.tar.gz", hash = "sha256:4be82589bf5c1d7999aedf2a45159d10cb3ca4f19b2271f8792bc8e6da7b22f6"}, -] - -[package.dependencies] -zipp = {version = ">=3.1.0", markers = "python_version < \"3.10\""} - -[package.extras] -docs = ["furo", "jaraco.packaging (>=9)", "jaraco.tidelift (>=1.4)", "rst.linker (>=1.9)", "sphinx (>=3.5)", "sphinx-lint"] -testing = ["flake8 (<5)", "pytest (>=6)", "pytest-black (>=0.3.7)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=1.3)", "pytest-flake8", "pytest-mypy (>=0.9.1)"] - [[package]] name = "inflect" version = "5.6.2" @@ -801,11 +719,12 @@ files = [ [package.dependencies] attrs = ">=17.4.0" -importlib-metadata = {version = "*", markers = "python_version < \"3.8\""} +setuptools = "*" +six = ">=1.11.0" importlib-resources = {version = ">=1.4.0", markers = "python_version < \"3.9\""} pkgutil-resolve-name = {version = ">=1.3.10", markers = "python_version < \"3.9\""} pyrsistent = ">=0.14.0,<0.17.0 || >0.17.0,<0.17.1 || >0.17.1,<0.17.2 || >0.17.2" -typing-extensions = {version = "*", markers = "python_version < \"3.8\""} + [package.extras] format = ["fqdn", "idna", "isoduration", "jsonpointer (>1.13)", "rfc3339-validator", "rfc3987", "uri-template", "webcolors (>=1.11)"] @@ -995,7 +914,6 @@ files = [ [package.dependencies] mypy-extensions = ">=1.0.0" tomli = {version = ">=1.1.0", markers = "python_version < \"3.11\""} -typed-ast = {version = ">=1.4.0,<2", markers = "python_version < \"3.8\""} typing-extensions = ">=4.1.0" [package.extras] @@ -1118,9 +1036,6 @@ files = [ {file = "platformdirs-4.0.0.tar.gz", hash = "sha256:cb633b2bcf10c51af60beb0ab06d2f1d69064b43abf4c185ca6b28865f3f9731"}, ] -[package.dependencies] -typing-extensions = {version = ">=4.7.1", markers = "python_version < \"3.8\""} - [package.extras] docs = ["furo (>=2023.7.26)", "proselint (>=0.13)", "sphinx (>=7.1.1)", "sphinx-autodoc-typehints (>=1.24)"] test = ["appdirs (==1.4.4)", "covdefaults (>=2.3)", "pytest (>=7.4)", "pytest-cov (>=4.1)", "pytest-mock (>=3.11.1)"] @@ -1136,9 +1051,6 @@ files = [ {file = "pluggy-1.2.0.tar.gz", hash = "sha256:d12f0c4b579b15f5e054301bb226ee85eeeba08ffec228092f8defbaa3a4c4b3"}, ] -[package.dependencies] -importlib-metadata = {version = ">=0.12", markers = "python_version < \"3.8\""} - [package.extras] dev = ["pre-commit", "tox"] testing = ["pytest", "pytest-benchmark"] @@ -1183,7 +1095,6 @@ files = [ [package.dependencies] cfgv = ">=2.0.0" identify = ">=1.0.0" -importlib-metadata = {version = "*", markers = "python_version < \"3.8\""} nodeenv = ">=0.11.1" pyyaml = ">=5.1" virtualenv = ">=20.10.0" @@ -1348,7 +1259,6 @@ files = [ [package.dependencies] colorama = {version = "*", markers = "sys_platform == \"win32\""} exceptiongroup = {version = ">=1.0.0rc8", markers = "python_version < \"3.11\""} -importlib-metadata = {version = ">=0.12", markers = "python_version < \"3.8\""} iniconfig = "*" packaging = "*" pluggy = ">=0.12,<2.0" @@ -1758,56 +1668,6 @@ files = [ {file = "tomli-2.0.1.tar.gz", hash = "sha256:de526c12914f0c550d15924c62d72abc48d6fe7364aa87328337a31007fe8a4f"}, ] -[[package]] -name = "typed-ast" -version = "1.5.5" -description = "a fork of Python 2 and 3 ast modules with type comment support" -optional = false -python-versions = ">=3.6" -files = [ - {file = "typed_ast-1.5.5-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:4bc1efe0ce3ffb74784e06460f01a223ac1f6ab31c6bc0376a21184bf5aabe3b"}, - {file = "typed_ast-1.5.5-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:5f7a8c46a8b333f71abd61d7ab9255440d4a588f34a21f126bbfc95f6049e686"}, - {file = "typed_ast-1.5.5-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:597fc66b4162f959ee6a96b978c0435bd63791e31e4f410622d19f1686d5e769"}, - {file = "typed_ast-1.5.5-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d41b7a686ce653e06c2609075d397ebd5b969d821b9797d029fccd71fdec8e04"}, - {file = "typed_ast-1.5.5-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:5fe83a9a44c4ce67c796a1b466c270c1272e176603d5e06f6afbc101a572859d"}, - {file = "typed_ast-1.5.5-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:d5c0c112a74c0e5db2c75882a0adf3133adedcdbfd8cf7c9d6ed77365ab90a1d"}, - {file = "typed_ast-1.5.5-cp310-cp310-win_amd64.whl", hash = "sha256:e1a976ed4cc2d71bb073e1b2a250892a6e968ff02aa14c1f40eba4f365ffec02"}, - {file = "typed_ast-1.5.5-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:c631da9710271cb67b08bd3f3813b7af7f4c69c319b75475436fcab8c3d21bee"}, - {file = "typed_ast-1.5.5-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:b445c2abfecab89a932b20bd8261488d574591173d07827c1eda32c457358b18"}, - {file = "typed_ast-1.5.5-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:cc95ffaaab2be3b25eb938779e43f513e0e538a84dd14a5d844b8f2932593d88"}, - {file = "typed_ast-1.5.5-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:61443214d9b4c660dcf4b5307f15c12cb30bdfe9588ce6158f4a005baeb167b2"}, - {file = "typed_ast-1.5.5-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:6eb936d107e4d474940469e8ec5b380c9b329b5f08b78282d46baeebd3692dc9"}, - {file = "typed_ast-1.5.5-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:e48bf27022897577d8479eaed64701ecaf0467182448bd95759883300ca818c8"}, - {file = "typed_ast-1.5.5-cp311-cp311-win_amd64.whl", hash = "sha256:83509f9324011c9a39faaef0922c6f720f9623afe3fe220b6d0b15638247206b"}, - {file = "typed_ast-1.5.5-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:44f214394fc1af23ca6d4e9e744804d890045d1643dd7e8229951e0ef39429b5"}, - {file = "typed_ast-1.5.5-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:118c1ce46ce58fda78503eae14b7664163aa735b620b64b5b725453696f2a35c"}, - {file = "typed_ast-1.5.5-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:be4919b808efa61101456e87f2d4c75b228f4e52618621c77f1ddcaae15904fa"}, - {file = "typed_ast-1.5.5-cp36-cp36m-musllinux_1_1_aarch64.whl", hash = "sha256:fc2b8c4e1bc5cd96c1a823a885e6b158f8451cf6f5530e1829390b4d27d0807f"}, - {file = "typed_ast-1.5.5-cp36-cp36m-musllinux_1_1_x86_64.whl", hash = "sha256:16f7313e0a08c7de57f2998c85e2a69a642e97cb32f87eb65fbfe88381a5e44d"}, - {file = "typed_ast-1.5.5-cp36-cp36m-win_amd64.whl", hash = "sha256:2b946ef8c04f77230489f75b4b5a4a6f24c078be4aed241cfabe9cbf4156e7e5"}, - {file = "typed_ast-1.5.5-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:2188bc33d85951ea4ddad55d2b35598b2709d122c11c75cffd529fbc9965508e"}, - {file = "typed_ast-1.5.5-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:0635900d16ae133cab3b26c607586131269f88266954eb04ec31535c9a12ef1e"}, - {file = "typed_ast-1.5.5-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:57bfc3cf35a0f2fdf0a88a3044aafaec1d2f24d8ae8cd87c4f58d615fb5b6311"}, - {file = "typed_ast-1.5.5-cp37-cp37m-musllinux_1_1_aarch64.whl", hash = "sha256:fe58ef6a764de7b4b36edfc8592641f56e69b7163bba9f9c8089838ee596bfb2"}, - {file = "typed_ast-1.5.5-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:d09d930c2d1d621f717bb217bf1fe2584616febb5138d9b3e8cdd26506c3f6d4"}, - {file = "typed_ast-1.5.5-cp37-cp37m-win_amd64.whl", hash = "sha256:d40c10326893ecab8a80a53039164a224984339b2c32a6baf55ecbd5b1df6431"}, - {file = "typed_ast-1.5.5-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:fd946abf3c31fb50eee07451a6aedbfff912fcd13cf357363f5b4e834cc5e71a"}, - {file = "typed_ast-1.5.5-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:ed4a1a42df8a3dfb6b40c3d2de109e935949f2f66b19703eafade03173f8f437"}, - {file = "typed_ast-1.5.5-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:045f9930a1550d9352464e5149710d56a2aed23a2ffe78946478f7b5416f1ede"}, - {file = "typed_ast-1.5.5-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:381eed9c95484ceef5ced626355fdc0765ab51d8553fec08661dce654a935db4"}, - {file = "typed_ast-1.5.5-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:bfd39a41c0ef6f31684daff53befddae608f9daf6957140228a08e51f312d7e6"}, - {file = "typed_ast-1.5.5-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:8c524eb3024edcc04e288db9541fe1f438f82d281e591c548903d5b77ad1ddd4"}, - {file = "typed_ast-1.5.5-cp38-cp38-win_amd64.whl", hash = "sha256:7f58fabdde8dcbe764cef5e1a7fcb440f2463c1bbbec1cf2a86ca7bc1f95184b"}, - {file = "typed_ast-1.5.5-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:042eb665ff6bf020dd2243307d11ed626306b82812aba21836096d229fdc6a10"}, - {file = "typed_ast-1.5.5-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:622e4a006472b05cf6ef7f9f2636edc51bda670b7bbffa18d26b255269d3d814"}, - {file = "typed_ast-1.5.5-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:1efebbbf4604ad1283e963e8915daa240cb4bf5067053cf2f0baadc4d4fb51b8"}, - {file = "typed_ast-1.5.5-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:f0aefdd66f1784c58f65b502b6cf8b121544680456d1cebbd300c2c813899274"}, - {file = "typed_ast-1.5.5-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:48074261a842acf825af1968cd912f6f21357316080ebaca5f19abbb11690c8a"}, - {file = "typed_ast-1.5.5-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:429ae404f69dc94b9361bb62291885894b7c6fb4640d561179548c849f8492ba"}, - {file = "typed_ast-1.5.5-cp39-cp39-win_amd64.whl", hash = "sha256:335f22ccb244da2b5c296e6f96b06ee9bed46526db0de38d2f0e5a6597b81155"}, - {file = "typed_ast-1.5.5.tar.gz", hash = "sha256:94282f7a354f36ef5dbce0ef3467ebf6a258e370ab33d5b40c249fa996e590dd"}, -] - [[package]] name = "typeguard" version = "2.13.3" @@ -1923,28 +1783,12 @@ files = [ [package.dependencies] distlib = ">=0.3.7,<1" filelock = ">=3.12.2,<4" -importlib-metadata = {version = ">=6.6", markers = "python_version < \"3.8\""} platformdirs = ">=3.9.1,<5" [package.extras] docs = ["furo (>=2023.7.26)", "proselint (>=0.13)", "sphinx (>=7.1.2,!=7.3)", "sphinx-argparse (>=0.4)", "sphinxcontrib-towncrier (>=0.2.1a0)", "towncrier (>=23.6)"] test = ["covdefaults (>=2.3)", "coverage (>=7.2.7)", "coverage-enable-subprocess (>=1)", "flaky (>=3.7)", "packaging (>=23.1)", "pytest (>=7.4)", "pytest-env (>=0.8.2)", "pytest-freezer (>=0.4.8)", "pytest-mock (>=3.11.1)", "pytest-randomly (>=3.12)", "pytest-timeout (>=2.1)", "setuptools (>=68)", "time-machine (>=2.10)"] -[[package]] -name = "zipp" -version = "3.15.0" -description = "Backport of pathlib-compatible object wrapper for zip files" -optional = false -python-versions = ">=3.7" -files = [ - {file = "zipp-3.15.0-py3-none-any.whl", hash = "sha256:48904fc76a60e542af151aded95726c1a5c34ed43ab4134b597665c86d7ad556"}, - {file = "zipp-3.15.0.tar.gz", hash = "sha256:112929ad649da941c23de50f356a2b5570c954b65150642bccdd66bf194d224b"}, -] - -[package.extras] -docs = ["furo", "jaraco.packaging (>=9)", "jaraco.tidelift (>=1.4)", "rst.linker (>=1.9)", "sphinx (>=3.5)", "sphinx-lint"] -testing = ["big-O", "flake8 (<5)", "jaraco.functools", "jaraco.itertools", "more-itertools", "pytest (>=6)", "pytest-black (>=0.3.7)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=1.3)", "pytest-flake8", "pytest-mypy (>=0.9.1)"] - [extras] debug = ["PySnooper"] graphql = ["graphql-core"] diff --git a/pyproject.toml b/pyproject.toml index 797ce0c87..e8c314643 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -14,7 +14,6 @@ classifiers = [ "Natural Language :: English", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", @@ -41,7 +40,7 @@ patterns = ["(^version: str = ')[^']*(')"] datamodel-codegen = "datamodel_code_generator.__main__:main" [tool.poetry.dependencies] -python = "^3.7" +python = "^3.8" pydantic = [ {extras = ["email"], version = ">=1.5.1,<3.0,!=2.4.0", python = "<3.10"}, {extras = ["email"], version = ">=1.9.0,<3.0,!=2.4.0", python = "~3.10"}, @@ -50,7 +49,7 @@ pydantic = [ ] argcomplete = ">=1.10,<4.0" jinja2 = ">=2.10.1,<4.0" -inflect = ">=4.1.0,<6.0" +inflect = ">=4.1.0,<8.0" black = ">=19.10b0" isort = ">=4.3.21,<6.0" genson = ">=1.2.1,<2.0" @@ -97,7 +96,7 @@ validation = ["prance", "openapi-spec-validator"] line-length = 88 extend-select = ['Q', 'RUF100', 'C4', 'UP', 'I'] flake8-quotes = {inline-quotes = 'single', multiline-quotes = 'double'} -target-version = 'py37' +target-version = 'py38' ignore = ['E501', 'UP006', 'UP007', 'Q000', 'Q003' ] extend-exclude = ['tests/data'] diff --git a/tests/data/expected/main/main_graphql_custom_scalar_types/output.py b/tests/data/expected/main/main_graphql_custom_scalar_types/output.py index 628a95971..0f6bc6df9 100644 --- a/tests/data/expected/main/main_graphql_custom_scalar_types/output.py +++ b/tests/data/expected/main/main_graphql_custom_scalar_types/output.py @@ -4,10 +4,9 @@ from __future__ import annotations -from typing import Optional, TypeAlias +from typing import Literal, Optional, TypeAlias from pydantic import BaseModel, Field -from typing_extensions import Literal Boolean: TypeAlias = bool """ diff --git a/tests/data/expected/main/main_graphql_different_types_of_fields/output.py b/tests/data/expected/main/main_graphql_different_types_of_fields/output.py index dd85384b0..63331d272 100644 --- a/tests/data/expected/main/main_graphql_different_types_of_fields/output.py +++ b/tests/data/expected/main/main_graphql_different_types_of_fields/output.py @@ -4,10 +4,9 @@ from __future__ import annotations -from typing import List, Optional, TypeAlias +from typing import List, Literal, Optional, TypeAlias from pydantic import BaseModel, Field -from typing_extensions import Literal Boolean: TypeAlias = bool """ diff --git a/tests/data/expected/main/main_graphql_field_aliases/output.py b/tests/data/expected/main/main_graphql_field_aliases/output.py index fd6c81671..669d08aa3 100644 --- a/tests/data/expected/main/main_graphql_field_aliases/output.py +++ b/tests/data/expected/main/main_graphql_field_aliases/output.py @@ -4,10 +4,9 @@ from __future__ import annotations -from typing import Optional, TypeAlias +from typing import Literal, Optional, TypeAlias from pydantic import BaseModel, Field -from typing_extensions import Literal Boolean: TypeAlias = bool """ diff --git a/tests/data/expected/main/main_graphql_simple_star_wars/output.py b/tests/data/expected/main/main_graphql_simple_star_wars/output.py index 1bc3d2bde..c94319836 100644 --- a/tests/data/expected/main/main_graphql_simple_star_wars/output.py +++ b/tests/data/expected/main/main_graphql_simple_star_wars/output.py @@ -4,10 +4,9 @@ from __future__ import annotations -from typing import List, Optional, TypeAlias +from typing import List, Literal, Optional, TypeAlias from pydantic import BaseModel, Field -from typing_extensions import Literal Boolean: TypeAlias = bool """ diff --git a/tests/data/expected/main/main_jsonschema_discriminator_literals/output.py b/tests/data/expected/main/main_jsonschema_discriminator_literals/output.py index 51d18b9f2..da91f1ac9 100644 --- a/tests/data/expected/main/main_jsonschema_discriminator_literals/output.py +++ b/tests/data/expected/main/main_jsonschema_discriminator_literals/output.py @@ -4,10 +4,9 @@ from __future__ import annotations -from typing import Union +from typing import Literal, Union from pydantic import BaseModel, Field -from typing_extensions import Literal class Type1(BaseModel): diff --git a/tests/data/expected/main/main_openapi_const_field_msgspec/output.py b/tests/data/expected/main/main_openapi_const_field_msgspec/output.py index 82ff26f92..a209342a7 100644 --- a/tests/data/expected/main/main_openapi_const_field_msgspec/output.py +++ b/tests/data/expected/main/main_openapi_const_field_msgspec/output.py @@ -4,8 +4,10 @@ from __future__ import annotations +from typing import Literal + from msgspec import Meta, Struct -from typing_extensions import Annotated, Literal +from typing_extensions import Annotated class Api(Struct): diff --git a/tests/data/expected/main/main_openapi_const_field_pydantic_v2/output.py b/tests/data/expected/main/main_openapi_const_field_pydantic_v2/output.py index 3487a2d7c..9081d5167 100644 --- a/tests/data/expected/main/main_openapi_const_field_pydantic_v2/output.py +++ b/tests/data/expected/main/main_openapi_const_field_pydantic_v2/output.py @@ -4,8 +4,9 @@ from __future__ import annotations +from typing import Literal + from pydantic import BaseModel, Field -from typing_extensions import Literal class Api(BaseModel): diff --git a/tests/data/expected/main/main_openapi_const_pydantic_v2/output.py b/tests/data/expected/main/main_openapi_const_pydantic_v2/output.py index b29bbb5fd..f64d03da4 100644 --- a/tests/data/expected/main/main_openapi_const_pydantic_v2/output.py +++ b/tests/data/expected/main/main_openapi_const_pydantic_v2/output.py @@ -4,8 +4,9 @@ from __future__ import annotations +from typing import Literal + from pydantic import BaseModel -from typing_extensions import Literal class Namespace(BaseModel): diff --git a/tests/data/expected/main/main_openapi_discriminator/output.py b/tests/data/expected/main/main_openapi_discriminator/output.py index 9cd6e45fa..d45395c50 100644 --- a/tests/data/expected/main/main_openapi_discriminator/output.py +++ b/tests/data/expected/main/main_openapi_discriminator/output.py @@ -5,10 +5,9 @@ from __future__ import annotations from enum import Enum -from typing import Optional, Union +from typing import Literal, Optional, Union from pydantic import BaseModel, Field -from typing_extensions import Literal class Type(Enum): diff --git a/tests/data/expected/main/main_openapi_discriminator_without_mapping/output.py b/tests/data/expected/main/main_openapi_discriminator_without_mapping/output.py index 2b91db084..9a4dfb26c 100644 --- a/tests/data/expected/main/main_openapi_discriminator_without_mapping/output.py +++ b/tests/data/expected/main/main_openapi_discriminator_without_mapping/output.py @@ -5,10 +5,9 @@ from __future__ import annotations from enum import Enum -from typing import Optional, Union +from typing import Literal, Optional, Union from pydantic import BaseModel, Field -from typing_extensions import Literal class Type(Enum): diff --git a/tests/data/expected/main/main_openapi_enum_models_as_literal_py37/output.py b/tests/data/expected/main/main_openapi_enum_models_as_literal_py37/output.py index 2f1a3a20b..40566d82b 100644 --- a/tests/data/expected/main/main_openapi_enum_models_as_literal_py37/output.py +++ b/tests/data/expected/main/main_openapi_enum_models_as_literal_py37/output.py @@ -4,10 +4,9 @@ from __future__ import annotations -from typing import List, Optional, Union +from typing import List, Literal, Optional, Union from pydantic import BaseModel, Field -from typing_extensions import Literal class Pet(BaseModel): diff --git a/tests/data/expected/main/main_typed_dict/output.py b/tests/data/expected/main/main_typed_dict/output.py index 5f57d8ba0..5fcf7611d 100644 --- a/tests/data/expected/main/main_typed_dict/output.py +++ b/tests/data/expected/main/main_typed_dict/output.py @@ -4,9 +4,9 @@ from __future__ import annotations -from typing import List +from typing import List, TypedDict -from typing_extensions import NotRequired, TypedDict +from typing_extensions import NotRequired class Pet(TypedDict): diff --git a/tests/data/expected/main/pyproject/output.py b/tests/data/expected/main/pyproject/output.py index e7a0dad04..0ad6508ae 100644 --- a/tests/data/expected/main/pyproject/output.py +++ b/tests/data/expected/main/pyproject/output.py @@ -2,6 +2,10 @@ # filename: api.yaml # timestamp: 2019-07-26T00:00:00+00:00 +from __future__ import ( + annotations, +) + from typing import ( List, Optional, @@ -21,7 +25,7 @@ class Pet(BaseModel): class Pets(BaseModel): - __root__: List["Pet"] + __root__: List[Pet] class User(BaseModel): @@ -31,7 +35,7 @@ class User(BaseModel): class Users(BaseModel): - __root__: List["User"] + __root__: List[User] class Id(BaseModel): @@ -79,7 +83,7 @@ class Api(BaseModel): class Apis(BaseModel): - __root__: List["Api"] + __root__: List[Api] class Event(BaseModel): @@ -87,4 +91,4 @@ class Event(BaseModel): class Result(BaseModel): - event: Optional["Event"] + event: Optional[Event] diff --git a/tests/data/expected/main/target_python_version/output.py b/tests/data/expected/main/target_python_version/output.py index 55f955a87..6e24ae1de 100644 --- a/tests/data/expected/main/target_python_version/output.py +++ b/tests/data/expected/main/target_python_version/output.py @@ -2,6 +2,8 @@ # filename: api.yaml # timestamp: 2019-07-26T00:00:00+00:00 +from __future__ import annotations + from typing import List, Optional from pydantic import AnyUrl, BaseModel, Field @@ -14,7 +16,7 @@ class Pet(BaseModel): class Pets(BaseModel): - __root__: List['Pet'] + __root__: List[Pet] class User(BaseModel): @@ -24,7 +26,7 @@ class User(BaseModel): class Users(BaseModel): - __root__: List['User'] + __root__: List[User] class Id(BaseModel): @@ -56,7 +58,7 @@ class Api(BaseModel): class Apis(BaseModel): - __root__: List['Api'] + __root__: List[Api] class Event(BaseModel): @@ -64,4 +66,4 @@ class Event(BaseModel): class Result(BaseModel): - event: Optional['Event'] = None + event: Optional[Event] = None diff --git a/tests/data/expected/main_kr/target_python_version/output.py b/tests/data/expected/main_kr/target_python_version/output.py index 55f955a87..6e24ae1de 100644 --- a/tests/data/expected/main_kr/target_python_version/output.py +++ b/tests/data/expected/main_kr/target_python_version/output.py @@ -2,6 +2,8 @@ # filename: api.yaml # timestamp: 2019-07-26T00:00:00+00:00 +from __future__ import annotations + from typing import List, Optional from pydantic import AnyUrl, BaseModel, Field @@ -14,7 +16,7 @@ class Pet(BaseModel): class Pets(BaseModel): - __root__: List['Pet'] + __root__: List[Pet] class User(BaseModel): @@ -24,7 +26,7 @@ class User(BaseModel): class Users(BaseModel): - __root__: List['User'] + __root__: List[User] class Id(BaseModel): @@ -56,7 +58,7 @@ class Api(BaseModel): class Apis(BaseModel): - __root__: List['Api'] + __root__: List[Api] class Event(BaseModel): @@ -64,4 +66,4 @@ class Event(BaseModel): class Result(BaseModel): - event: Optional['Event'] = None + event: Optional[Event] = None diff --git a/tests/data/expected/parser/openapi/openapi_parser_parse_enum_models/output_py36.py b/tests/data/expected/parser/openapi/openapi_parser_parse_enum_models/output_py36.py deleted file mode 100644 index 68b802c6a..000000000 --- a/tests/data/expected/parser/openapi/openapi_parser_parse_enum_models/output_py36.py +++ /dev/null @@ -1,136 +0,0 @@ -from enum import Enum -from typing import List, Optional, Union - -from pydantic import BaseModel, Field - - -class Kind(Enum): - dog = 'dog' - cat = 'cat' - - -class Type(Enum): - animal = 'animal' - - -class Number(Enum): - integer_1 = 1 - - -class Boolean(Enum): - boolean_True = True - - -class Pet(BaseModel): - id: int - name: str - tag: Optional[str] = None - kind: Optional['Kind'] = None - type: Optional['Type'] = None - number: 'Number' - boolean: 'Boolean' - - -class Pets(BaseModel): - __root__: List['Pet'] - - -class Kind1(Enum): - snake = 'snake' - rabbit = 'rabbit' - - -class Animal(BaseModel): - kind: Optional['Kind1'] = None - - -class Error(BaseModel): - code: int - message: str - - -class Type1(Enum): - a = 'a' - b = 'b' - - -class EnumObject(BaseModel): - type: Optional['Type1'] = None - - -class EnumRoot(Enum): - a = 'a' - b = 'b' - - -class IntEnum(Enum): - number_1 = 1 - number_2 = 2 - - -class AliasEnum(Enum): - a = 1 - b = 2 - c = 3 - - -class MultipleTypeEnum(Enum): - red = 'red' - amber = 'amber' - green = 'green' - NoneType_None = None - int_42 = 42 - - -class SingleEnum(Enum): - pet = 'pet' - - -class ArrayEnumEnum(Enum): - cat = 'cat' - - -class ArrayEnumEnum1(Enum): - dog = 'dog' - - -class ArrayEnum(BaseModel): - __root__: List[Union['ArrayEnumEnum', 'ArrayEnumEnum1']] - - -class NestedVersionEnum(Enum): - RC1 = 'RC1' - RC1N = 'RC1N' - RC2 = 'RC2' - RC2N = 'RC2N' - RC3 = 'RC3' - RC4 = 'RC4' - - -class NestedVersion(BaseModel): - __root__: Optional['NestedVersionEnum'] = Field( - 'RC1', description='nullable enum', example='RC2' - ) - - -class NestedNullableEnum(BaseModel): - nested_version: Optional['NestedVersion'] = Field( - default_factory=lambda: NestedVersion.parse_obj('RC1'), - description='nullable enum', - example='RC2', - ) - - -class VersionEnum(Enum): - RC1 = 'RC1' - RC1N = 'RC1N' - RC2 = 'RC2' - RC2N = 'RC2N' - RC3 = 'RC3' - RC4 = 'RC4' - - -class Version(BaseModel): - __root__: Optional['VersionEnum'] = Field( - 'RC1', description='nullable enum', example='RC2' - ) diff --git a/tests/data/expected/parser/openapi/openapi_parser_parse_enum_models/output_py37.py b/tests/data/expected/parser/openapi/openapi_parser_parse_enum_models/output_py38.py similarity index 100% rename from tests/data/expected/parser/openapi/openapi_parser_parse_enum_models/output_py37.py rename to tests/data/expected/parser/openapi/openapi_parser_parse_enum_models/output_py38.py diff --git a/tests/data/project/pyproject.toml b/tests/data/project/pyproject.toml index 67f060f72..296149056 100644 --- a/tests/data/project/pyproject.toml +++ b/tests/data/project/pyproject.toml @@ -10,7 +10,7 @@ validation = true field-constraints = true snake-case-field = true strip-default-none = true -target-python-version = "3.6" +target-python-version = "3.8" aliases = "ALIASES_PATH" extra-template-data = "EXTRA_TEMPLATE_DATA_PATH" custom-template-dir = "CUSTOM_TEMPLATE_DIR_PATH" diff --git a/tests/parser/test_openapi.py b/tests/parser/test_openapi.py index cb5b87369..0e7d3afd0 100644 --- a/tests/parser/test_openapi.py +++ b/tests/parser/test_openapi.py @@ -367,13 +367,13 @@ def test_openapi_parser_parse_enum_models(): Path(DATA_PATH / 'enum_models.yaml').read_text(), ) expected_dir = EXPECTED_OPEN_API_PATH / 'openapi_parser_parse_enum_models' - assert parser.parse() == (expected_dir / 'output_py37.py').read_text() + assert parser.parse() == (expected_dir / 'output_py38.py').read_text() parser = OpenAPIParser( Path(DATA_PATH / 'enum_models.yaml').read_text(), - target_python_version=PythonVersion.PY_36, + target_python_version=PythonVersion.PY_38, ) - assert parser.parse() == (expected_dir / 'output_py36.py').read_text() + assert parser.parse() == (expected_dir / 'output_py38.py').read_text() def test_openapi_parser_parse_anyof(): diff --git a/tests/test_format.py b/tests/test_format.py index 4274f093d..d68e1ced0 100644 --- a/tests/test_format.py +++ b/tests/test_format.py @@ -33,7 +33,7 @@ def test_format_code_with_skip_string_normalization( skip_string_normalization: bool, expected_output: str ) -> None: formatter = CodeFormatter( - PythonVersion.PY_37, skip_string_normalization=skip_string_normalization + PythonVersion.PY_38, skip_string_normalization=skip_string_normalization ) formatted_code = formatter.format_code("a = 'b'") diff --git a/tests/test_main.py b/tests/test_main.py index 05749077e..7c44a2965 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -198,7 +198,7 @@ def test_target_python_version(): '--output', str(output_file), '--target-python-version', - '3.6', + '3.8', ] ) assert return_code == Exit.OK @@ -1847,27 +1847,6 @@ def test_main_use_generic_container_types_standard_collections( assert result == path.read_text() -def test_main_use_generic_container_types_py36(capsys) -> None: - input_filename = OPEN_API_DATA_PATH / 'modular.yaml' - - return_code: Exit = main( - [ - '--input', - str(input_filename), - '--use-generic-container-types', - '--target-python-version', - '3.6', - ] - ) - captured = capsys.readouterr() - assert return_code == Exit.ERROR - assert ( - captured.err == '`--use-generic-container-types` can not be used with ' - '`--target-python_version` 3.6.\n ' - 'The version will be not supported in a future version\n' - ) - - def test_main_original_field_name_delimiter_without_snake_case_field(capsys) -> None: input_filename = OPEN_API_DATA_PATH / 'modular.yaml' @@ -2508,6 +2487,7 @@ def test_main_openapi_enum_models_as_literal_py37(capsys): ) + @freeze_time('2019-07-26') def test_main_root_model_with_additional_properties(): with TemporaryDirectory() as output_dir: @@ -5219,7 +5199,7 @@ def test_main_disable_warnings_config(capsys: CaptureFixture): 'jsonschema', '--use-union-operator', '--target-python-version', - '3.6', + '3.8', '--disable-warnings', ] ) diff --git a/tests/test_main_kr.py b/tests/test_main_kr.py index 13e157f04..1b50e08e8 100644 --- a/tests/test_main_kr.py +++ b/tests/test_main_kr.py @@ -85,7 +85,7 @@ def test_target_python_version(): '--output', str(output_file), '--target-python-version', - '3.6', + '3.8', ] ) assert return_code == Exit.OK