Closed
Description
Although the parameter collect_by_mro
is implemented in
Lines 994 to 1017 in 48157a5
it is missing it the typed signature of the pyi file
Lines 257 to 303 in 48157a5
As a consequence, type checkers such as mypy
would never allow to use collect_by_mro
, since the signature cannot match, although in runtime it would work because the actual implementation of the function has the parameter.
Activity
hynek commentedon Nov 3, 2020
Thanks, should be fixed.
raabf commentedon Nov 3, 2020
Thank you @hynek 😄, but didn’t you miss the type annotation?
i.e.
collect_by_mro: bool = ...,
instead ofcollect_by_mro = ...,
?hynek commentedon Nov 3, 2020
Waaat. Why does the test pass then. 🤔 Probably implicit Any?
Add types to collect_by_mro annotations m(
hynek commentedon Nov 3, 2020
Should be fixed now. Thanks for double-checking!
raabf commentedon Nov 3, 2020
Thanks! Regarding the test which passes:
I did not find any mypy configuration for the attrs repository. The think the default configuration of mypy allows untyped elements, and just checks those which are typed. To detect such errors like missing types, you should make mypy more restrictive such as with
disallow_untyped_defs = True
andcheck_untyped_defs = True
, which I think is good when you want to be serious regarding full compatibility with mypy.hynek commentedon Nov 4, 2020
You're right, that's how I run my own projects too.
attrs
's typing setup is a bit more special but this we should add. See 6b4a1f1Bump attrs from 20.2.0 to 20.3.0 (#5207)
Bump attrs from 20.2.0 to 20.3.0 (aio-libs#5207)
Bump attrs from 20.2.0 to 20.3.0 (aio-libs#5207)
Add missing collect_by_mro to typing stubs