lkml.org 
[lkml]   [2021]   [Oct]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH] kunit: tool: fix typecheck errors about loading qemu configs
On Thu, Oct 21, 2021 at 5:49 PM 'Daniel Latypov' via KUnit Development
<kunit-dev@googlegroups.com> wrote:
>
> Currently, we have these errors:
> $ mypy ./tools/testing/kunit/*.py
> tools/testing/kunit/kunit_kernel.py:213: error: Item "_Loader" of "Optional[_Loader]" has no attribute "exec_module"
> tools/testing/kunit/kunit_kernel.py:213: error: Item "None" of "Optional[_Loader]" has no attribute "exec_module"
> tools/testing/kunit/kunit_kernel.py:214: error: Module has no attribute "QEMU_ARCH"
> tools/testing/kunit/kunit_kernel.py:215: error: Module has no attribute "QEMU_ARCH"
>
> exec_module
> ===========
>
> pytype currently reports no errors, but that's because there's a comment
> disabling it on 213.
>
> This is due to https://github.com/python/typeshed/pull/2626.
> The fix is to assert the loaded module implements the ABC
> (abstract base class) we want which has exec_module support.
>
> QEMU_ARCH
> =========
>
> pytype is fine with this, but mypy is not:
> https://github.com/python/mypy/issues/5059
>
> Add a check that the loaded module does indeed have QEMU_ARCH.
> Note: this is not enough to appease mypy, so we also add a comment to
> squash the warning.
>
> Signed-off-by: Daniel Latypov <dlatypov@google.com>

Thanks! I could not figure out how to make this work for both type
checkers on my own.

Reviewed-by: Brendan Higgins <brendanhiggins@google.com>

\
 
 \ /
  Last update: 2021-10-25 23:27    [W:0.049 / U:0.144 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site