Skip to content

Conversation

@ogrisel
Copy link
Contributor

@ogrisel ogrisel commented Oct 1, 2018

This should fix #207.

@codecov-io
Copy link

codecov-io commented Oct 1, 2018

Codecov Report

Merging #208 into master will decrease coverage by 0.37%.
The diff coverage is 80%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #208      +/-   ##
==========================================
- Coverage   85.16%   84.79%   -0.38%     
==========================================
  Files           1        1              
  Lines         573      572       -1     
  Branches      111      112       +1     
==========================================
- Hits          488      485       -3     
- Misses         62       63       +1     
- Partials       23       24       +1
Impacted Files Coverage Δ
cloudpickle/cloudpickle.py 84.79% <80%> (-0.38%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 06b18af...4ab821c. Read the comment docs.

Copy link
Contributor

@tomMoral tomMoral left a comment

Choose a reason for hiding this comment

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

Some comments on your PR.

def _find_module(mod_name):
def _can_find_module(mod_name):
"""
Iterate over each part instead of calling imp.find_module directly.
Copy link
Contributor

Choose a reason for hiding this comment

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

This comment is not accurate anymore.

file.close()
return path, description
if hasattr(importlib, 'util'):
spec = importlib.util.find_spec(mod_name)
Copy link
Contributor

Choose a reason for hiding this comment

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

Note that using this on submodules will import the parent modules.

See the Warning in this SO answer

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch: this is embarrassing as the old method based on imp does not have such a side effect. I don't know what should be done.

valid_module = imp.new_module('valid_module')
_find_module('valid_module')
dynamic_module = types.ModuleType('dynamic_module') # noqa
assert not _can_find_module('dynamic_module')
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't we also test it for sub-modules?

return False

if hasattr(module, '__spec__'):
return module.__spec__ is None
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice one!! This is indeed better

Copy link
Contributor Author

@ogrisel ogrisel Oct 2, 2018

Choose a reason for hiding this comment

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

The old imp-based code is fishy to me anyway. I cannot find a valid use case where __file__ would not be defined and the imp-based thingy would work.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In particular, I cannot build a valid case that would make it possible to have perfect coverage of the _is_dynamic function.

I don't think it was covered either before.

path = None
for part in mod_name.split('.'):
if path is not None:
path = [path]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This line, in particular, was never covered by past tests.

@ogrisel ogrisel merged commit abea4e6 into cloudpipe:master Oct 8, 2018
@ogrisel ogrisel deleted the fix-deprecation-warnings branch October 8, 2018 14:20
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.

DeprecationWarning: the imp module is deprecated in favour of importlib

3 participants