Skip to content
This repository has been archived by the owner on Nov 3, 2023. It is now read-only.

match-dir does not include files in subdirectories #363

Open
desecho opened this issue May 3, 2019 · 5 comments · May be fixed by #529
Open

match-dir does not include files in subdirectories #363

desecho opened this issue May 3, 2019 · 5 comments · May be fixed by #529

Comments

@desecho
Copy link

desecho commented May 3, 2019

Let's say I use an option --match-dir='^src' and have a folder src and I want to match everything inside this folder including files in subfolders, currently it skips all files inside subfolders

@nre-ableton
Copy link

This issue is also tripping me up. I have a project where I'd like to exclude certain third-party directories, but using match_dir means that pydocstyle no longer searches recursively for files.

So a practical example: in my config file, I have:

[pydocstyle]
match_dir = (\.|foo|tests)
match = .*\.py

This will match files in the top-level folder, foo/a.py, and tests/test_a.py. It will not match foo/bar/b.py nor tests/bar/test_b.py.

I have also tried: (\.|foo.*|tests.*), (\.|foo/.*|tests/.*), and (\.|foo/bar|tests/bar), all with the same result.

@xmnlab
Copy link

xmnlab commented Oct 22, 2019

it seems that match and match_dir just check the pattern over the dir and file name .. not the full absolute or relative path ... is there a reason for that?

maybe I don't understand well the reasons .. but my first guess is that would be easier to apply the a match pattern using as parameter the full relative path (the absolute path could have an undesirable result).

probably related to this method https://github.com/PyCQA/pydocstyle/blob/master/src/pydocstyle/config.py#L124

toryhaavik pushed a commit to ibis-project/ibis that referenced this issue Oct 29, 2019
In this PR:    - Fixed omniscidb docstrings  - Fixed some docstrings
- Added pydocstyle check for ./ibis/.py and ./ibis/omniscidb/*.py
Current issues with pydocstyle:    -
PyCQA/pydocstyle#111  -
PyCQA/pydocstyle#363
Author: Ivan Ogasawara <ivan.ogasawara@gmail.com>

Closes #1996 from xmnlab/add-docstring-check and squashes the following commits:

bcda303 [Ivan Ogasawara] Fixed pydocstyle command.
55ff381 [Ivan Ogasawara] Add pydocstyle match-dir parameter into CI recipe.
5b270e8 [Ivan Ogasawara] Add docstring check to CI and git pre-commit hook
@rmorshea
Copy link
Contributor

rmorshea commented Feb 28, 2020

For backward compatibility reasons there would probably need to be a match_path option that, by default, matched everything.

@jamesbraza
Copy link

The only thing I could get to work was excluding directories by following the example here. I also could not figure out how to use a positive filter.

[pydocstyle]
match = (?!test_).*\.py
match_dir = ^(?!(venv|ci_tests|some_sub_dir)).*

@theconsolelogger
Copy link

theconsolelogger commented Dec 26, 2020

Has there been any developments with matching directories using --match-dir? I would like to exclude all directories except for the directories mentioned in --match-dir.

Currently, I am trying to pass --match-dir as an argument to pydocstyle when using it as a pre-commit hook, however, it seems to not exclude directories and instead includes all directories.

An example of my .pre-commit-config.yaml file:

repos:
  ...
  - repo: https://github.com/pycqa/pydocstyle
    rev: 5.1.1
    hooks:
      - id: pydocstyle
        args:
          - --match-dir='^(src).*'

Solution

Pre-commit can restrict the files that are passed to pydocstyle using the files key, for example:

repos:
- repo: https://github.com/pycqa/pydocstyle
  rev: 5.1.1
  hooks:
  - id: pydocstyle
    files: ^src/

More information can be found here.

heoga added a commit to heoga/pydocstyle that referenced this issue Apr 1, 2021
It has been noted in issue PyCQA#363 that match & match_dir are
unwieldy when attempting to match against full paths.  For
unexample if you have A.py in directories B & C and you only
want to run pydocstyle on one of them.

From my own experience trying to deploy pydocstyle against a
large legacy codebase it is unworkable as it would mean the
entire codebase being converted as a big bang change. A more
nuanced approach means the codebase can be converted gradually.

This commit adds a new option, match_path, to the config &
command lines which can be used to provide more nuanced
matching.  For example the following specification:

match_path = [AB]/[ab].py
             D/e.py

This defines two regexes.  If either match a given path,
relative to the directory specified, the file will be yielded
for comparison.  The is complimentary to match & match_dir and
the three can be used together.
jpmckinney added a commit to open-contracting/software-development-handbook that referenced this issue Nov 22, 2021
Zeitsperre added a commit to Ouranosinc/xclim that referenced this issue May 9, 2022
…et all linting functions to use setup.cfg for pydocstyle,
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants