﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
30612	cached_property breaks type checking	dms-cat	nobody	"To reproduce:

1. Use a strict mypy configuration:
{{{
[mypy]
check_untyped_defs = true
disallow_untyped_defs = true
ignore_missing_imports = true
no_implicit_optional = true
warn_redundant_casts = true
warn_return_any = true
warn_unused_ignores = true
}}}
1. Create a model method which returns an optional instance:
{{{
@property
def area(self) -> Optional[Area]:
}}}
1. Try to use this elsewhere as though it's not optional: `instance.area.code`
1. Verify that `mypy` catches this issue:
{{{
error: Item ""None"" of ""Optional[Area]"" has no attribute ""code""
}}}
1. Change the `@property` annotation to `@cached_property`.

What happens:

`mypy` stops complaining about the broken typing.

What should happen:

`mypy` should still complain like above."	Bug	closed	Utilities	dev	Normal	invalid			Unreviewed	0	0	0	0	0	0
