Skip to content

Commit

Permalink
Exclude frozen importlib functions in default code filter. (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
carljm committed Dec 16, 2017
1 parent 2f682ef commit 1b4fe11
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Changelog
master
------

* Exclude "frozen importlib" functions in default code filter.
* Fix passing args to script run with ``monkeytype run`` (#18; merge of #21).
* Fix generated annotations for NewType types (#22; merge of #23).

Expand Down
2 changes: 2 additions & 0 deletions monkeytype/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ def include_unparsable_defaults(self) -> bool:
lib_paths.add(
sysconfig.get_path('stdlib', vars={'installed_base': venv_real_prefix})
)
# exclude code objects from frozen importlib, which have a bogus co_filename
lib_paths.add('<frozen importlib.')
LIB_PATHS = tuple(p for p in lib_paths if p is not None)


Expand Down
4 changes: 4 additions & 0 deletions tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree. An additional grant
# of patent rights can be found in the PATENTS file in the same directory.
import _frozen_importlib
import sysconfig

import pytest
Expand All @@ -20,3 +21,6 @@ def test_excludes_site_packages(self):

def test_includes_otherwise(self):
assert config.default_code_filter(config.default_code_filter.__code__)

def test_excludes_frozen_importlib(self):
assert not config.default_code_filter(_frozen_importlib.spec_from_loader.__code__)

0 comments on commit 1b4fe11

Please sign in to comment.