This repository was archived by the owner on Nov 3, 2023. It is now read-only.
File tree 3 files changed +28
-2
lines changed
3 files changed +28
-2
lines changed Original file line number Diff line number Diff line change @@ -15,6 +15,10 @@ New Features
15
15
* Add support for Python 3.10 (#554).
16
16
* Replace D10X errors with D419 if docstring exists but is empty (#559).
17
17
18
+ Bug Fixes
19
+
20
+ * Fix ``--match `` option to only consider filename when matching full paths (#550).
21
+
18
22
6.1.1 - May 17th, 2021
19
23
---------------------------
20
24
Original file line number Diff line number Diff line change @@ -288,7 +288,7 @@ def _get_property_decorators(conf):
288
288
# Skip any dirs that do not match match_dir
289
289
dirs [:] = [d for d in dirs if match_dir (d )]
290
290
291
- for filename in filenames :
291
+ for filename in map ( os . path . basename , filenames ) :
292
292
if match (filename ):
293
293
full_path = os .path .join (root , filename )
294
294
yield (
@@ -302,7 +302,7 @@ def _get_property_decorators(conf):
302
302
match , _ = _get_matches (config )
303
303
ignore_decorators = _get_ignore_decorators (config )
304
304
property_decorators = _get_property_decorators (config )
305
- if match (name ):
305
+ if match (os . path . basename ( name ) ):
306
306
yield (
307
307
name ,
308
308
list (config .checked_codes ),
Original file line number Diff line number Diff line change @@ -1489,3 +1489,25 @@ def test_comment_with_noqa_plus_docstring_file(env):
1489
1489
out , _ , code = env .invoke ()
1490
1490
assert '' == out
1491
1491
assert code == 0
1492
+
1493
+
1494
+ def test_match_considers_basenames_for_path_args (env ):
1495
+ """Test that `match` option only considers basenames for path arguments.
1496
+
1497
+ The test environment consists of a single empty module `test_a.py`. The
1498
+ match option is set to a pattern that ignores test_ prefixed .py filenames.
1499
+ When pydocstyle is invoked with full path to `test_a.py`, we expect it to
1500
+ succeed since match option will match against just the file name and not
1501
+ full path.
1502
+ """
1503
+ # Ignore .py files prefixed with 'test_'
1504
+ env .write_config (select = 'D100' , match = '(?!test_).+.py' )
1505
+
1506
+ # Create an empty module (violates D100)
1507
+ with env .open ('test_a.py' , 'wt' ) as test :
1508
+ test .write ('' )
1509
+
1510
+ # env.invoke calls pydocstyle with full path to test_a.py
1511
+ out , _ , code = env .invoke (target = 'test_a.py' )
1512
+ assert '' == out
1513
+ assert code == 0
You can’t perform that action at this time.
0 commit comments