Skip to content
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

use shell globs on file name for include/exclude patterns #137

Closed
wants to merge 1 commit into from

Conversation

beniwohli
Copy link
Contributor

The previously used module path was very brittle. Especially in the
case of Django, where the default include_path was the set of
INSTALLED_APPS, this would have a lot of false positives, namely
all 3rd party Django apps.

Using the lib/python exclude patterns should work for all cases that
use virtualenvs or the system python.

@beniwohli beniwohli force-pushed the include-patterns-glob branch 3 times, most recently from 7fec857 to da11fd9 Compare January 19, 2018 16:49
if not tmp_client:
_client = (client, instance)
return instance
return _client[1]


def get_client_default_config():
return dict(
include_paths=_get_installed_apps_paths(),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like _get_installed_apps_paths was only called from here, could remove that function too

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

excellent point!

@graphaelli
Copy link
Member

I'm unclear on what will happen on windows but noticed your TODO, not sure how you normally handle that.

@beniwohli
Copy link
Contributor Author

Regarding Windows, I did a quick test with Python 3.6

>>> import fnmatch
>>> print(fnmatch.__file__)
C:\Users\IEUser\project\elastic\py36\lib\fnmatch.py
>>> import django
>>> print(django.__file__)
C:\Users\IEUser\project\elastic\py36\lib\site-packages\django\__init__.py

So ['*\lib\*'] would work on Windows, but it's quite unspecific, so the chance for false positives is relatively high.

(py36 in the above example is just the name of my virtualenv, so can't use that in the pattern).

I'll do some more tests with Python 2 and pypy and then add Windows-specific patterns.

@beniwohli beniwohli force-pushed the include-patterns-glob branch 2 times, most recently from 6d1276c to d8071b0 Compare January 22, 2018 09:11
The previously used module path was very brittle. Especially in the
case of Django, where the default `include_path` was the set of
`INSTALLED_APPS`, this would have a lot of false positives, namely
all 3rd party Django apps.

Using the `lib/python` exclude patterns should work for all cases that
use virtualenvs or the system python.
@beniwohli beniwohli closed this in fddf91d Jan 24, 2018
beniwohli added a commit that referenced this pull request Jan 24, 2018
The previously used module path was very brittle. Especially in the
case of Django, where the default `include_path` was the set of
`INSTALLED_APPS`, this would have a lot of false positives, namely
all 3rd party Django apps.

Using the `lib/python` exclude patterns should work for all cases that
use virtualenvs or the system python.

closes #137
@beniwohli beniwohli deleted the include-patterns-glob branch January 24, 2018 16:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants