Skip to content

Commit

Permalink
mypy: made type checking opt-out
Browse files Browse the repository at this point in the history
  • Loading branch information
Augusto F. Hack committed Feb 3, 2022
1 parent 49627ba commit 6c297e4
Show file tree
Hide file tree
Showing 3 changed files with 167 additions and 20 deletions.
16 changes: 12 additions & 4 deletions karapace/compatibility/jsonschema/checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,11 @@
)


def type_mismatch(reader_type, writer_type, location: List[str]) -> SchemaCompatibilityResult:
def type_mismatch(
reader_type: JSONSCHEMA_TYPES,
writer_type: JSONSCHEMA_TYPES,
location: List[str],
) -> SchemaCompatibilityResult:
return SchemaCompatibilityResult.incompatible(
incompat_type=Incompatibility.type_changed,
message=f"type {reader_type} is not compatible with type {writer_type}",
Expand Down Expand Up @@ -189,7 +193,11 @@ def compatibility(reader: Draft7Validator, writer: Draft7Validator) -> SchemaCom


def check_simple_subschema(
simplified_reader_schema, simplified_writer_schema, original_reader_type, original_writer_type, location
simplified_reader_schema: Any,
simplified_writer_schema: Any,
original_reader_type: JSONSCHEMA_TYPES,
original_writer_type: JSONSCHEMA_TYPES,
location: List[str],
) -> SchemaCompatibilityResult:
rec_result = compatibility_rec(simplified_reader_schema, simplified_writer_schema, location)
if is_compatible(rec_result):
Expand Down Expand Up @@ -307,7 +315,7 @@ def check_assertion_compatibility(
)

# The type error below is due to a mypy bug for version 0.820 (issue #10131)
if assertion_check.comparison(reader_value, writer_value): # type: ignore
if assertion_check.comparison(reader_value, writer_value): # type: ignore[call-arg]
result.add_incompatibility(
incompat_type=assertion_check.error_when_restricting,
message=assertion_check.error_msg_when_restricting.format(
Expand Down Expand Up @@ -816,7 +824,7 @@ def compatibility_subschemas(reader_schema, writer_schema, location: List[str])
qty_of_required_compatible_subschemas = len_writer_subschemas

compatible_schemas_count = count_uniquely_compatible_schemas(
reader_type,
reader_type, # type: ignore
reader_subschemas,
writer_subschemas,
subschema_location,
Expand Down
2 changes: 1 addition & 1 deletion karapace/compatibility/jsonschema/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def normalize_schema(validator: Draft7Validator) -> Any:
return normalize_schema_rec(validator, original_schema)


def normalize_schema_rec(validator, original_schema) -> Any:
def normalize_schema_rec(validator: Draft7Validator, original_schema: Any) -> Any:
if isinstance(original_schema, (bool, str, float, int)) or original_schema is None:
return original_schema

Expand Down
169 changes: 154 additions & 15 deletions mypy.ini
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
[mypy]
python_version = 3.7
warn_redundant_casts = True

[mypy-karapace.*]
ignore_errors = True

[mypy-karapace.avro_compatibility]
ignore_errors = False
disallow_untyped_defs = True
disallow_incomplete_defs = True
Expand All @@ -16,13 +11,157 @@ warn_no_return = True
warn_unreachable = True
strict_equality = True

[mypy-karapace.compatibility]
ignore_errors = False
disallow_untyped_defs = True
disallow_incomplete_defs = True
check_untyped_defs = True
no_implicit_optional = True
warn_unused_ignores = True
warn_no_return = True
warn_unreachable = True
strict_equality = True
[mypy-karapace.schema_registry_apis]
ignore_errors = True

[mypy-karapace.karapace]
ignore_errors = True

[mypy-karapace]
ignore_errors = True

[mypy-karapace.version]
ignore_errors = True

[mypy-karapace.compatibility.jsonschema.checks]
disallow_untyped_defs = False
disallow_incomplete_defs = False
warn_unused_ignores = False

[mypy-karapace.constants]
ignore_errors = True

[mypy-karapace.karapace_all]
ignore_errors = True

[mypy-karapace.protobuf.one_of_element]
ignore_errors = True

[mypy-karapace.protobuf.syntax]
ignore_errors = True

[mypy-karapace.protobuf.field]
ignore_errors = True

[mypy-karapace.protobuf.kotlin_wrapper]
ignore_errors = True

[mypy-karapace.protobuf.io]
ignore_errors = True

[mypy-karapace.protobuf.field_element]
ignore_errors = True

[mypy-karapace.protobuf.proto_file_element]
ignore_errors = True

[mypy-karapace.protobuf.compare_type_storage]
ignore_errors = True

[mypy-karapace.protobuf.type_element]
ignore_errors = True

[mypy-karapace.protobuf.enum_element]
ignore_errors = True

[mypy-karapace.protobuf.encoding_variants]
ignore_errors = True

[mypy-karapace.protobuf]
ignore_errors = True

[mypy-karapace.protobuf.schema]
ignore_errors = True

[mypy-karapace.protobuf.extensions_element]
ignore_errors = True

[mypy-karapace.protobuf.protobuf_to_dict]
ignore_errors = True

[mypy-karapace.protobuf.exception]
ignore_errors = True

[mypy-karapace.protobuf.rpc_element]
ignore_errors = True

[mypy-karapace.protobuf.option_reader]
ignore_errors = True

[mypy-karapace.protobuf.option_element]
ignore_errors = True

[mypy-karapace.protobuf.enum_constant_element]
ignore_errors = True

[mypy-karapace.protobuf.compare_result]
ignore_errors = True

[mypy-karapace.protobuf.location]
ignore_errors = True

[mypy-karapace.protobuf.message_element]
ignore_errors = True

[mypy-karapace.protobuf.syntax_reader]
ignore_errors = True

[mypy-karapace.protobuf.utils]
ignore_errors = True

[mypy-karapace.protobuf.extend_element]
ignore_errors = True

[mypy-karapace.protobuf.reserved_element]
ignore_errors = True

[mypy-karapace.protobuf.proto_type]
ignore_errors = True

[mypy-karapace.protobuf.group_element]
ignore_errors = True

[mypy-karapace.protobuf.service_element]
ignore_errors = True

[mypy-karapace.protobuf.proto_parser]
ignore_errors = True

[mypy-karapace.config]
ignore_errors = True

[mypy-karapace.schema_reader]
ignore_errors = True

[mypy-karapace.statsd]
ignore_errors = True

[mypy-karapace.utils]
ignore_errors = True

[mypy-karapace.rapu]
ignore_errors = True

[mypy-karapace.serialization]
ignore_errors = True

[mypy-karapace.master_coordinator]
ignore_errors = True

[mypy-karapace.kafka_rest_apis.__main__]
ignore_errors = True

[mypy-karapace.kafka_rest_apis.consumer_manager]
ignore_errors = True

[mypy-karapace.kafka_rest_apis]
ignore_errors = True

[mypy-karapace.kafka_rest_apis.admin]
ignore_errors = True

[mypy-karapace.kafka_rest_apis.error_codes]
ignore_errors = True

[mypy-karapace.schema_backup]
ignore_errors = True

0 comments on commit 6c297e4

Please sign in to comment.