Skip to content

a way to exclude directories from files or ignore errors in certain directories #8309

@brianmaissy

Description

@brianmaissy

I have a use case for which I am having trouble finding a way to configure my mypy.ini.

I have a project which includes (for whatever legacy reason) a directory containing nested subdirectories (not modules) of python scripts inside my codebase.

The directory structure is something like this:

myproject/
    __init__.py
    submodule/
        __init__.py
        ...
    another_submodule/
        __init__.py
        ...
    scripts/
        __init__.py
        dir1/
            script1.py
        dir2/
            script2.py

These files are included in my files=myproject/**/*.py wildcard, but I would like to find a way to exclude them from mypy (or to ignore errors found in them).

I can define ignore_errors = True for specific submodules, but the scripts are not part the myproject.scripts module because the subdirectories aren't modules.

Obviously the correct solution is to move the scripts directory outside of the myproject module, but let's say that isn't within my power.

I could also create __init__.py files in all of the subdirectories (and nested subdirectories), turning them into artificial modules, but let's also that that isn't within my power.

What I'm looking for is a way to define a wildcard of files to be excluded from the files= configuration parameter, or a way to define a subsection in the configuration file based on a files wildcard rather than a module wildcard, and then I can configure ignore_errors = True.

Is there some other suggested solution, or could something along the lines of one of these be implemented?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions