Skip to content

pyproject.toml exclude needs validation or better type handling #561

@daggaz

Description

@daggaz

When defining a pyproject.toml with the exclude option, and not understanding that it must be a list, people (me) write things like:

[tool.diff_cover]
exclude = "some/file.py"

Because strings are iterable, this ends up here, calling fnmatch() on each item in ['s', 'o', 'm', 'e', '/', 'f', 'i', 'l', 'e', '.', 'p', 'y'].

Very confusing.

And when you include a * that ends up always excluding everything, which make you think you've succeeded, when in fact you just entirely disabled the tool.

I think that it should either be an error to pass a plain string, or perhaps more helpfully adding if isinstance(patterns, str): patterns = [patterns], allowing both exclude = "string" and exclude = ["strings"].

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