Merge pull request #1555 from larsoner/hidden

FIX: --check-hidden respects directories
diff --git a/codespell_lib/_codespell.py b/codespell_lib/_codespell.py
index e7b72b7..b629161 100755
--- a/codespell_lib/_codespell.py
+++ b/codespell_lib/_codespell.py
@@ -304,8 +304,8 @@
 
     parser.add_argument('-H', '--check-hidden',
                         action='store_true', default=False,
-                        help='check hidden files (those starting with ".") as '
-                             'well')
+                        help='Check hidden files and directories (those '
+                             'starting with ".") as well.')
     parser.add_argument('-A', '--after-context', type=int, metavar='LINES',
                         help='print LINES of trailing context')
     parser.add_argument('-B', '--before-context', type=int, metavar='LINES',
@@ -715,6 +715,8 @@
                 if glob_match.match(root):  # skip (absolute) directories
                     del dirs[:]
                     continue
+                if is_hidden(root, options.check_hidden):  # dir itself hidden
+                    continue
                 for file_ in files:
                     # ignore hidden files in directories
                     if is_hidden(file_, options.check_hidden):
diff --git a/codespell_lib/tests/test_basic.py b/codespell_lib/tests/test_basic.py
index 47cf94a..b766451 100644
--- a/codespell_lib/tests/test_basic.py
+++ b/codespell_lib/tests/test_basic.py
@@ -5,6 +5,7 @@
 import contextlib
 import os
 import os.path as op
+from shutil import copyfile
 import subprocess
 import sys
 
@@ -321,6 +322,16 @@
     assert cs.main('--check-hidden', '--check-filenames',
                    op.join(d, '.abandonned.txt')) == 2
     assert cs.main('--check-hidden', '--check-filenames', d) == 2
+    # hidden directory
+    assert cs.main(d) == 0
+    assert cs.main('--check-hidden', d) == 1
+    assert cs.main('--check-hidden', '--check-filenames', d) == 2
+    os.mkdir(op.join(d, '.abandonned'))
+    copyfile(op.join(d, '.abandonned.txt'),
+             op.join(d, '.abandonned', 'abandonned.txt'))
+    assert cs.main(d) == 0
+    assert cs.main('--check-hidden', d) == 2
+    assert cs.main('--check-hidden', '--check-filenames', d) == 5
 
 
 def test_case_handling(tmpdir, capsys):