mirror of
https://github.com/koxudaxi/datamodel-code-generator.git
synced 2024-03-18 14:54:37 +03:00
[pre-commit.ci] pre-commit autoupdate (#1883)
* [pre-commit.ci] pre-commit autoupdate updates: - [github.com/astral-sh/ruff-pre-commit: v0.2.2 → v0.3.2](https://github.com/astral-sh/ruff-pre-commit/compare/v0.2.2...v0.3.2) * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
f89af5536b
commit
862a98cb7e
@@ -1,6 +1,6 @@
|
||||
repos:
|
||||
- repo: https://github.com/astral-sh/ruff-pre-commit
|
||||
rev: 'v0.2.2'
|
||||
rev: 'v0.3.2'
|
||||
hooks:
|
||||
- id: ruff
|
||||
files: "^datamodel_code_generator|^tests"
|
||||
|
||||
@@ -58,8 +58,7 @@ def load_yaml_from_path(path: Path, encoding: str) -> Any:
|
||||
|
||||
if TYPE_CHECKING:
|
||||
|
||||
def get_version() -> str:
|
||||
...
|
||||
def get_version() -> str: ...
|
||||
|
||||
else:
|
||||
|
||||
|
||||
@@ -94,8 +94,7 @@ class Config(BaseModel):
|
||||
if TYPE_CHECKING:
|
||||
|
||||
@classmethod
|
||||
def get_fields(cls) -> Dict[str, Any]:
|
||||
...
|
||||
def get_fields(cls) -> Dict[str, Any]: ...
|
||||
|
||||
else:
|
||||
|
||||
|
||||
@@ -76,8 +76,7 @@ class PythonVersion(Enum):
|
||||
|
||||
if TYPE_CHECKING:
|
||||
|
||||
class _TargetVersion(Enum):
|
||||
...
|
||||
class _TargetVersion(Enum): ...
|
||||
|
||||
BLACK_PYTHON_VERSION: Dict[PythonVersion, _TargetVersion]
|
||||
else:
|
||||
@@ -98,8 +97,7 @@ def black_find_project_root(sources: Sequence[Path]) -> Path:
|
||||
|
||||
def _find_project_root(
|
||||
srcs: Union[Sequence[str], Iterable[str]],
|
||||
) -> Union[Tuple[Path, str], Path]:
|
||||
...
|
||||
) -> Union[Tuple[Path, str], Path]: ...
|
||||
|
||||
else:
|
||||
from black import find_project_root as _find_project_root
|
||||
@@ -153,9 +151,9 @@ class CodeFormatter:
|
||||
f' for wrapping string literal in {black.__version__}'
|
||||
)
|
||||
elif black.__version__ < '24.1.0': # type: ignore
|
||||
black_kwargs[
|
||||
'experimental_string_processing'
|
||||
] = experimental_string_processing
|
||||
black_kwargs['experimental_string_processing'] = (
|
||||
experimental_string_processing
|
||||
)
|
||||
elif experimental_string_processing:
|
||||
black_kwargs['preview'] = True
|
||||
black_kwargs['unstable'] = config.get('unstable', False)
|
||||
@@ -240,8 +238,7 @@ class CodeFormatter:
|
||||
|
||||
if TYPE_CHECKING:
|
||||
|
||||
def apply_isort(self, code: str) -> str:
|
||||
...
|
||||
def apply_isort(self, code: str) -> str: ...
|
||||
|
||||
else:
|
||||
if isort.__version__.startswith('4.'):
|
||||
|
||||
@@ -267,8 +267,7 @@ class TemplateBase(ABC):
|
||||
return self.render()
|
||||
|
||||
|
||||
class BaseClassDataType(DataType):
|
||||
...
|
||||
class BaseClassDataType(DataType): ...
|
||||
|
||||
|
||||
UNDEFINED: Any = object()
|
||||
|
||||
@@ -408,19 +408,19 @@ class Parser(ABC):
|
||||
self.base_class: Optional[str] = base_class
|
||||
self.target_python_version: PythonVersion = target_python_version
|
||||
self.results: List[DataModel] = []
|
||||
self.dump_resolve_reference_action: Optional[
|
||||
Callable[[Iterable[str]], str]
|
||||
] = dump_resolve_reference_action
|
||||
self.dump_resolve_reference_action: Optional[Callable[[Iterable[str]], str]] = (
|
||||
dump_resolve_reference_action
|
||||
)
|
||||
self.validation: bool = validation
|
||||
self.field_constraints: bool = field_constraints
|
||||
self.snake_case_field: bool = snake_case_field
|
||||
self.strip_default_none: bool = strip_default_none
|
||||
self.apply_default_values_for_required_fields: (
|
||||
bool
|
||||
) = apply_default_values_for_required_fields
|
||||
self.force_optional_for_required_fields: (
|
||||
bool
|
||||
) = force_optional_for_required_fields
|
||||
self.apply_default_values_for_required_fields: bool = (
|
||||
apply_default_values_for_required_fields
|
||||
)
|
||||
self.force_optional_for_required_fields: bool = (
|
||||
force_optional_for_required_fields
|
||||
)
|
||||
self.use_schema_description: bool = use_schema_description
|
||||
self.use_field_description: bool = use_field_description
|
||||
self.use_default_kwarg: bool = use_default_kwarg
|
||||
@@ -433,9 +433,9 @@ class Parser(ABC):
|
||||
self.use_generic_container_types: bool = use_generic_container_types
|
||||
self.use_union_operator: bool = use_union_operator
|
||||
self.enable_faux_immutability: bool = enable_faux_immutability
|
||||
self.custom_class_name_generator: Optional[
|
||||
Callable[[str], str]
|
||||
] = custom_class_name_generator
|
||||
self.custom_class_name_generator: Optional[Callable[[str], str]] = (
|
||||
custom_class_name_generator
|
||||
)
|
||||
self.field_extra_keys: Set[str] = field_extra_keys or set()
|
||||
self.field_extra_keys_without_x_prefix: Set[str] = (
|
||||
field_extra_keys_without_x_prefix or set()
|
||||
@@ -568,9 +568,9 @@ class Parser(ABC):
|
||||
|
||||
def __delete_duplicate_models(self, models: List[DataModel]) -> None:
|
||||
model_class_names: Dict[str, DataModel] = {}
|
||||
model_to_duplicate_models: DefaultDict[
|
||||
DataModel, List[DataModel]
|
||||
] = defaultdict(list)
|
||||
model_to_duplicate_models: DefaultDict[DataModel, List[DataModel]] = (
|
||||
defaultdict(list)
|
||||
)
|
||||
for model in models[:]:
|
||||
if isinstance(model, self.data_model_root_type):
|
||||
root_data_type = model.fields[0].data_type
|
||||
|
||||
@@ -632,9 +632,9 @@ class JsonSchemaParser(Parser):
|
||||
|
||||
def set_additional_properties(self, name: str, obj: JsonSchemaObject) -> None:
|
||||
if isinstance(obj.additionalProperties, bool):
|
||||
self.extra_template_data[name][
|
||||
'additionalProperties'
|
||||
] = obj.additionalProperties
|
||||
self.extra_template_data[name]['additionalProperties'] = (
|
||||
obj.additionalProperties
|
||||
)
|
||||
|
||||
def set_title(self, name: str, obj: JsonSchemaObject) -> None:
|
||||
if obj.title:
|
||||
|
||||
@@ -23,8 +23,7 @@ if TYPE_CHECKING:
|
||||
|
||||
from typing_extensions import Literal
|
||||
|
||||
def load_toml(path: Path) -> Dict[str, Any]:
|
||||
...
|
||||
def load_toml(path: Path) -> Dict[str, Any]: ...
|
||||
|
||||
else:
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user