Skip to content

Ignore mypy errors from site-packages imports #134

Open
@intgr

Description

@intgr

Mypy by default silences all errors that come from installed third party packages in site-packages. This can be disabled with the --no-silence-site-packages flag.

However, they are not silenced in pytest-mypy-plugins tests and I don't see a way to enable that behavior.

For example in typeddjango/djangorestframework-stubs#480 I enabled disallow_untyped_defs and disallow_incomplete_defs options, but then I got mypy errors from yaml-stubs package:

_________________________________________________________________________________________________ test_override_get_permissions _________________________________________________________________________________________________
/Users/marti.raudsepp/own/djangorestframework-stubs/tests/typecheck/test_views.yml:69: 
E   pytest_mypy_plugins.utils.TypecheckAssertionError: Output is not expected: 
E   Actual:
E     ../../../../../../[...]/djangorestframework-stubs/.venv/lib/python3.11/site-packages/yaml-stubs/__init__.pyi:29: error: Function is missing a type annotation (diff)
E     ../../../../../../[...]/djangorestframework-stubs/.venv/lib/python3.11/site-packages/yaml-stubs/__init__.pyi:30: error: Function is missing a return type annotation (diff)
... lots more ...

As a work-around, I can just suppress these in mypy.ini

[mypy-yaml.*]
disallow_untyped_defs = false
disallow_incomplete_defs = false

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions