Pylint gets confused: No name 'path' in module 'path' #102

Closed
nedbat opened this Issue Aug 24, 2015 · 16 comments

Comments

Projects
None yet
10 participants

nedbat commented Aug 24, 2015

Pylint doesn't understand that path.py defines the name "path". It does so with the @alias decorator, which is only used once in the file. So there are six extra lines of code to define a decorator which only serves to confuse pylint.

Would you mind getting rid of the decorator and replacing it with path = Path? Then pylint will understand.

sarina commented Aug 24, 2015

👍

@jaraco jaraco closed this in 62ccb76 Aug 27, 2015

This latest fix (release 8.0) breaks compatibility with other packages using path.py (in particular pickleshare, which is used in ipython / jupyter). I had to revert to release 7.7.1 for now to get ipython working again.

It looks like pickleshare uses path.py like this: from path import path as Path and may need to be updated now, but I thought anyone else who has this problem might wanted to know.

Traceback (most recent call last):
  File "/usr/local/bin/ipython", line 7, in <module>
    from IPython import start_ipython
  File "/usr/local/lib/python2.7/site-packages/IPython/__init__.py", line 48, in <module>
    from .terminal.embed import embed
  File "/usr/local/lib/python2.7/site-packages/IPython/terminal/embed.py", line 16, in <module>
    from IPython.core.interactiveshell import DummyMod
  File "/usr/local/lib/python2.7/site-packages/IPython/core/interactiveshell.py", line 31, in <module>
    from pickleshare import PickleShareDB
  File "/usr/local/lib/python2.7/site-packages/pickleshare.py", line 41, in <module>
    from path import path as Path
ImportError: cannot import name path

nedbat commented Aug 27, 2015

Wow, this isn't what I was hoping for at all. Why break the public interface of the package?

Well, it was broken around a major release boundary, so one could say at least this wasn't done with a 7.8.0 release. But still, I've had to revert back to 7.7.1 as well, as tools I need depend on the previous public interface.

Owner

jaraco commented Aug 27, 2015

The intention has been to remove the deprecated path name since the 6.2 release, which was made almost a year ago, so this change was planned. The presence of the alias was to make the path name easily visible alongside the canonical Path declaration, rather than burying it near the end of the file.

The client libraries should be able to require path.py >= 6.2 and change their imports to reference the preferred name.

whitmo commented Aug 27, 2015

is keeping path = Path really that big a deal? this change just broken a huge amount of code we are running here at canonical. 😿 🙍

Contributor

Nodd commented Aug 27, 2015

@whitmo 👍
"almost one year ago" isn't very far in the past for lots of codebases. Given that a simple path = Path keeps back compatibility, it seems logical to keep it. A big warning in the documentation would be useful too.

Owner

jaraco commented Aug 27, 2015

Fair enough.

@jaraco are we going to see a backwords compat release hit pypi? This is effecting by and large about 30 projects that I'm aware of here in the Juju ecosystem alone, I'm willing to bet it spins much larger when you start looking at other tools we're using.

Owner

jaraco commented Aug 27, 2015

I've pulled 8.0 from PyPI

Thanks! We'll start going through and pinning our dependencies so its far less of an impact when design decisions like this surface in the future. Thanks for the rapid response @jaraco

chuckbutler added a commit to chuckbutler/etcd-charm that referenced this issue Aug 27, 2015

Pin the package of path.py to prevent breakage
Due to bug 102 jaraco/path.py#102 path.py was
recently updated to remove an alias of "path" and this breaks thing in a
big way which warranted moving from inline dependency statements to
tracking deps.

This may not be an immediate issue anymore, but we're better off
tracking dependencies in a requirements.txt so we can mitigate design
changes like this moving forward

chuckbutler added a commit to chuckbutler/docker-charm that referenced this issue Aug 27, 2015

Pin path.py
Due to bug 102 jaraco/path.py#102 path.py was
recently updated to remove an alias of "path" and this breaks thing in a
big way which warranted moving from inline dependency statements to
tracking deps.

This may not be an immediate issue anymore, but we're better off
tracking dependencies in a requirements.txt so we can mitigate design
changes like this moving forward

chuckbutler added a commit to chuckbutler/swarm-charm that referenced this issue Aug 27, 2015

Pin path.py
Due to bug 102 jaraco/path.py#102 path.py was
recently updated to remove an alias of "path" and this breaks thing in a
big way which warranted moving from inline dependency statements to
tracking deps.

This may not be an immediate issue anymore, but we're better off
tracking dependencies in a requirements.txt so we can mitigate design
changes like this moving forward

chuckbutler added a commit to chuckbutler/swarm-charm that referenced this issue Aug 27, 2015

Pin path.py
Due to bug 102 jaraco/path.py#102 path.py was
recently updated to remove an alias of "path" and this breaks thing in a
big way which warranted moving from inline dependency statements to
tracking deps.

This may not be an immediate issue anymore, but we're better off
tracking dependencies in a requirements.txt so we can mitigate design
changes like this moving forward

chuckbutler added a commit to chuckbutler/swarm-charm that referenced this issue Aug 27, 2015

Pin path.py
Due to bug 102 jaraco/path.py#102 path.py was
recently updated to remove an alias of "path" and this breaks thing in a
big way which warranted moving from inline dependency statements to
tracking deps.

This may not be an immediate issue anymore, but we're better off
tracking dependencies in a requirements.txt so we can mitigate design
changes like this moving forward

chuckbutler added a commit to chuckbutler/swarm-charm that referenced this issue Aug 27, 2015

Pin path.py
Due to bug 102 jaraco/path.py#102 path.py was
recently updated to remove an alias of "path" and this breaks thing in a
big way which warranted moving from inline dependency statements to
tracking deps.

This may not be an immediate issue anymore, but we're better off
tracking dependencies in a requirements.txt so we can mitigate design
changes like this moving forward

chuckbutler added a commit to chuckbutler/swarm-charm that referenced this issue Aug 27, 2015

Pin path.py
Due to bug 102 jaraco/path.py#102 path.py was
recently updated to remove an alias of "path" and this breaks thing in a
big way which warranted moving from inline dependency statements to
tracking deps.

This may not be an immediate issue anymore, but we're better off
tracking dependencies in a requirements.txt so we can mitigate design
changes like this moving forward

@chuckbutler chuckbutler referenced this issue in whitmo/swarm-charm Aug 27, 2015

Closed

Pin path.py #2

nedbat added a commit to edx/edx-platform that referenced this issue Aug 27, 2015

Change imports from path to use the stablest name.
The old line:

    from path import path

produced pylint errors because of the baroque way that path.py defined
"path".  We tried to get them to change how they defined it, but they
deleted the name instead: jaraco/path.py#102

(Jason then changed his mind, but this is a better way to use path.py,
it avoids the pylint error at least.)

IPython 4.0.0 (and previous) will do from path import * which doesn't work with 8.1 since path isn't in __all__. It also declares path.py as a requirement without pinning a version, so running pip install ipython on a clean install will give you a broken ipython

I'm going to pin 7.7.1 in my project now as a workaround.

@codewarrior0 could you specifically show how you did this? I tried to reinstall 7.7.1 for path.py but my Ipython 4.0.0 is still broken. Is there a specific version I should be using for pickleshare?

I don't know about pickleshare. I must have been wrong about IPython 4.0.0, as it doesn't seem to be broken on a clean install - but IPython 3.2.1 certainly is.

Here's what I did to get a broken IPython:

$ virtualenv ipytest
$ . ipytest/scripts/activate
$ pip install ipython==3.2.1
$ ipython
[...]
  File "ipytest\lib\site-packages\IPython\utils\text.py", line 28, in <module>
    from IPython.external.path import path
ImportError: cannot import name path

(IPython/external/path/__init__.py does from path import *)

And this is what it took to fix it:

$ pip install py.path==7.7.1
$ ipython
[...]
IPython 3.2.1 -- An enhanced Interactive Python.

In [1]:

Cool thanks! Worked for me. Definitely looking forward to a fix in IPython 4.0.0.

@kunanit kunanit referenced this issue in mitodl/edx2bigquery Oct 19, 2017

Closed

Depreciated import from path.py #63

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment