-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add --ignore flag to ignore files/directories #14
Conversation
Alias `-I`, can be used multiple times
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, this looks good! For this to be merged, I'd like to see some tests for the new feature, and maybe a one-line note in the changelog.
Co-authored-by: Marius Gedminas <marius@gedmin.as>
Done the changes |
Excellent! Now the only missing thing is unit tests for the new code:
It would be easier to write the tests after some refactoring of the code. I would extract the filtering logic into a separate method: def filterIgnoes(self, dirs, files, ignores):
for ignore in ignores:
if ignore in dirs:
dirs.remove(ignore)
if ignore in files:
files.remove(ignore) call it inside parsePathname(), and then write a test like def test_filterIgnores(self):
dirs = ['venv', 'submodule']
files = ['code.py', 'README.txt']
mg = findImports.ModuleGraph()
mg.filterIgnores(dirs, files, ignores=['venv', 'README.txt'])
self.assertEqual(dirs, ['submodule'])
self.assertEqual(files, ['code.py']) in tests.py, next to the parsePathname test. |
I was busy lately but I will try to make the changes tomorrow. |
There's no rush! ;) |
Separated the logic in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me!
Ignore a file or directory; this option can be used | ||
multiple times. Default: ['venv'] | ||
|
||
FindImports requires Python 3.6 or later. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh wow, and I'd totally forgotten that there was a usage message in the docstring! Thank you for noticing and updating it!
(This code is old, these days I'd rely on argparse-generated help messages, and maybe put a copy in the README for new user convenience, and then usually forget to update it when making changes.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm making modules too so I know the feeling when I forget to update docs 😅
I've pushed a new release to PyPI. |
Add --ignore flag to ignore files/directories
Alias
-I
, can be used multiple times