Skip to content

Filter out non-Python source files #3848

@tjpnz

Description

@tjpnz

I utilize CodeSpell to enforce US spelling as part of an internal Python coding standard. Most of the code bases it checks live inside mono repos where there'll be a lot of CPP source files and configuration. When I invoke CodeSpell it will find issues across all files, but I would like the ability for it to only check Python files.

What I've tried

Filtering out patterns using skip - not really practical since it expects me to know which files might exist in a repo ahead of time. I did notice that CodeSpell uses fnmatch under the hood which claims to support negative matches using !, but I wasn't able get this to work for matching non *.py patterns.

Passing a list of Python files - messy since I need to do a glob first and then filter out the Python files I want to skip (tests, files under .venv etc.)

What I would like to see

A global option to restrict checks to *.py files. It would respect both skip and any Python files I pass to the command.


Any pointers on how this could be achieved currently would be welcome! If it's not I would be open to pushing a PR if an approach could be agreed on.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions