Skip to content

Commit

Permalink
Merge pull request #772 from Aiven-Open/dependabot/pip/requirements/m…
Browse files Browse the repository at this point in the history
…ypy-1.7.1

build(deps): bump mypy from 1.6.1 to 1.7.1 in /requirements
  • Loading branch information
tvainika authored Dec 1, 2023
2 parents d823422 + 2b29ada commit 83157fa
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 20 deletions.
31 changes: 15 additions & 16 deletions karapace/avro_dataclasses/introspect.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,14 @@ def _field_type(field: Field, type_: object) -> AvroType: # pylint: disable=too

# Handle enums.
if isinstance(type_, type) and issubclass(type_, Enum):
return EnumType(
{
# Conditionally set a default.
**({"default": field.default.value} if field.default is not MISSING else {}),
"name": type_.__name__,
"type": "enum",
"symbols": [value.value for value in type_],
}
)
enum_dict: EnumType = {
"name": type_.__name__,
"type": "enum",
"symbols": [value.value for value in type_],
}
if field.default is not MISSING:
enum_dict["default"] = field.default.value
return enum_dict

# Handle map types.
if origin is Mapping:
Expand All @@ -115,13 +114,13 @@ def _field_type(field: Field, type_: object) -> AvroType: # pylint: disable=too
raise UnderspecifiedAnnotation("Key and value types must be specified for map types")
if args[0] is not str:
raise UnsupportedAnnotation("Key type must be str")
return MapType(
{
"type": "map",
"values": _field_type(field, args[1]),
**({"default": field.default_factory()} if field.default_factory is not MISSING else {}),
}
)
map_dict: MapType = {
"type": "map",
"values": _field_type(field, args[1]),
}
if field.default_factory is not MISSING:
map_dict["default"] = field.default_factory()
return map_dict

raise NotImplementedError(
f"Found an unknown type {type_!r} while assembling Avro schema for the field "
Expand Down
1 change: 0 additions & 1 deletion karapace/avro_dataclasses/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ class EnumType(TypedDict):


class MapType(TypedDict):
name: str
type: Literal["map"]
values: AvroType
default: NotRequired[Mapping[str, AvroType]]
Expand Down
1 change: 0 additions & 1 deletion mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ warn_unused_ignores = True
warn_no_return = True
warn_unreachable = True
strict_equality = True
enable_incomplete_feature = Unpack

[mypy-karapace.schema_registry_apis]
ignore_errors = True
Expand Down
14 changes: 12 additions & 2 deletions requirements/requirements-typing.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,34 @@
attrs==23.1.0
# via
# -c requirements-dev.txt
# -c requirements.txt
# referencing
certifi==2023.7.22
# via
# -c requirements-dev.txt
# sentry-sdk
mypy==1.6.1
mypy==1.7.1
# via -r requirements-typing.in
mypy-extensions==1.0.0
# via mypy
referencing==0.30.0
# via
# -c requirements-dev.txt
# -c requirements.txt
# types-jsonschema
rpds-py==0.9.2
# via
# -c requirements-dev.txt
# -c requirements.txt
# referencing
sentry-sdk==1.31.0
# via -r requirements-typing.in
# via
# -c requirements-dev.txt
# -r requirements-typing.in
tomli==2.0.1
# via
# -c requirements-dev.txt
# mypy
types-cachetools==5.3.0.7
# via -r requirements-typing.in
types-jsonschema==4.19.0.4
Expand All @@ -35,6 +44,7 @@ types-protobuf==3.20.3
typing-extensions==4.6.3
# via
# -c requirements-dev.txt
# -c requirements.txt
# mypy
urllib3==2.0.7
# via
Expand Down

0 comments on commit 83157fa

Please sign in to comment.