Skip to content

Commit 14ebc5a

Browse files
committed
fix(missing): correct the -e, --exclude
The exclude should be append arbitrary number of path with .git is the builtin option [PLM-417]
1 parent a886df1 commit 14ebc5a

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

src/missing.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ class Missing:
1111
RE_TEST_PY = re.compile(r'test.*?\.py')
1212

1313
def __init__(self, exclude):
14+
if not (isinstance(exclude, list) or isinstance(exclude, tuple)):
15+
raise TypeError('exclude should be list or tuple')
16+
17+
# append .git to exclude folder
18+
exclude = set(['.git', *exclude])
19+
1420
# normalize a pathname by collapsing redundant separators
1521
self._exclude = [os.path.normpath(path) for path in exclude]
1622

@@ -73,7 +79,7 @@ def _find_for_unittest(self, basedir: Optional[str] = None) -> bool:
7379

7480
def main() -> int:
7581
parser = argparse.ArgumentParser(description='Find the missing but necessary files')
76-
parser.add_argument('-e', '--exclude', type=list, default=['.git'], help='exclude the file or folder')
82+
parser.add_argument('-e', '--exclude', nargs='*', help='exclude the file or folder')
7783
parser.add_argument('-q', '--quite', action='store_true', default=False, help='disable all log')
7884
args = parser.parse_args()
7985

@@ -85,7 +91,7 @@ def main() -> int:
8591
handler = logging.StreamHandler()
8692
logger.addHandler(handler)
8793

88-
missing = Missing(args.exclude)
94+
missing = Missing(args.exclude or [])
8995
return missing.run()
9096

9197
if __name__ == '__main__':

0 commit comments

Comments
 (0)