From e4e962b08b351caa655fe93045bbe01db4e3582e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Lafr=C3=A9choux?= Date: Sun, 6 Aug 2023 00:20:47 +0200 Subject: [PATCH 1/2] Add field_mapping type hint --- src/apispec/ext/marshmallow/field_converter.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/apispec/ext/marshmallow/field_converter.py b/src/apispec/ext/marshmallow/field_converter.py index d075aca6..2bf8a9de 100644 --- a/src/apispec/ext/marshmallow/field_converter.py +++ b/src/apispec/ext/marshmallow/field_converter.py @@ -6,6 +6,7 @@ This module is treated as private API. Users should not need to use this module directly. """ +from __future__ import annotations import re import functools import operator @@ -18,7 +19,7 @@ # marshmallow field => (JSON Schema type, format) -DEFAULT_FIELD_MAPPING = { +DEFAULT_FIELD_MAPPING: dict[type, tuple[str | None, str | None]] = { marshmallow.fields.Integer: ("integer", None), marshmallow.fields.Number: ("number", None), marshmallow.fields.Float: ("number", None), @@ -86,7 +87,7 @@ class FieldConverterMixin: """Adds methods for converting marshmallow fields to an OpenAPI properties.""" - field_mapping = DEFAULT_FIELD_MAPPING + field_mapping: dict[type, tuple[str | None, str | None]] = DEFAULT_FIELD_MAPPING openapi_version: Version def init_attribute_functions(self): From fa45620d04145ce3dd6fa7d055f972597d68ccf6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Lafr=C3=A9choux?= Date: Sun, 6 Aug 2023 00:23:36 +0200 Subject: [PATCH 2/2] pre-commit autoupdate --- .pre-commit-config.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d6975b1b..4376766e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,21 +1,21 @@ repos: - repo: https://github.com/asottile/pyupgrade - rev: v3.8.0 + rev: v3.10.1 hooks: - id: pyupgrade args: [--py37-plus] - repo: https://github.com/psf/black - rev: 23.3.0 + rev: 23.7.0 hooks: - id: black language_version: python3 - repo: https://github.com/pycqa/flake8 - rev: 6.0.0 + rev: 6.1.0 hooks: - id: flake8 additional_dependencies: [flake8-bugbear==22.12.6] - repo: https://github.com/asottile/blacken-docs - rev: 1.14.0 + rev: 1.15.0 hooks: - id: blacken-docs additional_dependencies: [black==22.3.0]