mirror of
https://github.com/PyCQA/flake8.git
synced 2026-04-13 16:14:18 +00:00
Merge branch 'exclude_dotfiles' into 'master'
Fix using --exclude=.* to not match `.` and `..` Closes #632 See merge request pycqa/flake8!424
This commit is contained in:
commit
4f5513869b
2 changed files with 9 additions and 1 deletions
|
|
@ -448,7 +448,7 @@ def matches_filename(path, patterns, log_message, logger):
|
||||||
if not patterns:
|
if not patterns:
|
||||||
return False
|
return False
|
||||||
basename = os.path.basename(path)
|
basename = os.path.basename(path)
|
||||||
if fnmatch(basename, patterns):
|
if basename not in {".", ".."} and fnmatch(basename, patterns):
|
||||||
logger.debug(log_message, {"path": basename, "whether": ""})
|
logger.debug(log_message, {"path": basename, "whether": ""})
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
"""Tests for flake8's utils module."""
|
"""Tests for flake8's utils module."""
|
||||||
|
import logging
|
||||||
import os
|
import os
|
||||||
|
|
||||||
import mock
|
import mock
|
||||||
|
|
@ -296,3 +297,10 @@ MULTI_FILE_INFO = {
|
||||||
def test_parse_unified_diff(diff, parsed_diff):
|
def test_parse_unified_diff(diff, parsed_diff):
|
||||||
"""Verify that what we parse from a diff matches expectations."""
|
"""Verify that what we parse from a diff matches expectations."""
|
||||||
assert utils.parse_unified_diff(diff) == parsed_diff
|
assert utils.parse_unified_diff(diff) == parsed_diff
|
||||||
|
|
||||||
|
|
||||||
|
def test_matches_filename_for_excluding_dotfiles():
|
||||||
|
"""Verify that `.` and `..` are not matched by `.*`."""
|
||||||
|
logger = logging.Logger(__name__)
|
||||||
|
assert not utils.matches_filename('.', ('.*',), '', logger)
|
||||||
|
assert not utils.matches_filename('..', ('.*',), '', logger)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue