Skip to content

Commit

Permalink
chore(mypy): enable truthy-bool error code (#3824)
Browse files Browse the repository at this point in the history
  • Loading branch information
sobolevn authored Nov 2, 2024
1 parent ed35b61 commit c354e36
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 11 deletions.
2 changes: 1 addition & 1 deletion litestar/_openapi/schema_generation/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ def for_object_type(self, field_definition: FieldDefinition) -> Schema:
if field_definition.is_non_string_sequence or field_definition.is_non_string_iterable:
# filters out ellipsis from tuple[int, ...] type annotations
inner_types = (f for f in field_definition.inner_types if f.annotation is not Ellipsis)
items = list(map(self.for_field_definition, inner_types or ()))
items = list(map(self.for_field_definition, inner_types))

return Schema(
type=OpenAPIType.ARRAY,
Expand Down
2 changes: 1 addition & 1 deletion litestar/_openapi/typescript_converter/converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ def convert_openapi_to_typescript(openapi_schema: OpenAPI, namespace: str = "API
"""
if not openapi_schema.paths: # pragma: no cover
raise ValueError("OpenAPI schema has no paths")
if not openapi_schema.components: # pragma: no cover
if not openapi_schema.components: # type: ignore[truthy-bool] # pragma: no cover
raise ValueError("OpenAPI schema has no components")

operations: list[TypeScriptNamespace] = []
Expand Down
4 changes: 1 addition & 3 deletions litestar/security/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,8 @@ def on_app_init(self, app_config: AppConfig) -> AppConfig:
app_config.openapi_config = copy(app_config.openapi_config)
if isinstance(app_config.openapi_config.components, list):
app_config.openapi_config.components.append(self.openapi_components)
elif app_config.openapi_config.components:
app_config.openapi_config.components = [self.openapi_components, app_config.openapi_config.components]
else:
app_config.openapi_config.components = [self.openapi_components]
app_config.openapi_config.components = [self.openapi_components, app_config.openapi_config.components]

if isinstance(app_config.openapi_config.security, list):
app_config.openapi_config.security.append(self.security_requirement)
Expand Down
11 changes: 5 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ xfail_strict = true
packages = ["litestar", "tests"]
plugins = ["pydantic.mypy"]
enable_error_code = [
"truthy-bool",
"truthy-iterable",
"unused-awaitable",
"ignore-without-code",
Expand All @@ -256,21 +257,19 @@ enable_error_code = [
python_version = "3.8"

disallow_any_generics = false
disallow_untyped_decorators = true
implicit_reexport = false
show_error_codes = true
strict = true
warn_redundant_casts = true
warn_return_any = true
warn_unreachable = true
warn_unused_configs = true
warn_unused_ignores = true
local_partial_types = true

[[tool.mypy.overrides]]
ignore_errors = true
module = ["tests.examples.*", "tests.docker_service_fixtures"]

[[tool.mypy.overrides]]
module = ["tests.*"]
disable_error_code = ["truthy-bool"]

[[tool.mypy.overrides]]
disallow_untyped_decorators = false
module = ["tests.unit.test_kwargs.test_reserved_kwargs_injection"]
Expand Down

0 comments on commit c354e36

Please sign in to comment.