jason-kane/PyYapf

Error on windows 8

jongmmm opened this issue · 1 comments

I get the following error.

Also set in the config {"yapf_command": "c:/miniconda3/envs/py37/Scripts/yapf"}

Traceback (most recent call last):
  File "C:\Program Files\Sublime Text 3\sublime_plugin.py", line 1088, in run_
    return self.run(edit)
  File "C:\Users\jjjmmm\AppData\Roaming\Sublime Text 3\Installed Packages\PyYapf Python Formatter.sublime-package\PyYapf.py", line 489, in run
  File "C:\Users\jjjmmm\AppData\Roaming\Sublime Text 3\Installed Packages\PyYapf Python Formatter.sublime-package\PyYapf.py", line 168, in __enter__
  File "./python3.3/shlex.py", line 276, in split
  File "./python3.3/shlex.py", line 266, in __next__
  File "./python3.3/shlex.py", line 93, in get_token
  File "./python3.3/shlex.py", line 121, in read_token
AttributeError: 'NoneType' object has no attribute 'read'

you might get a little more information with "debug": true in the pyyapf settings. Specifically I would be interested in something like "Found yapf: ", it seems like it is ignoring your yapf_command and ending up with a None but looking at the code I don't see how that would happen.

I would patch in (https://github.com/jason-kane/PyYapf/blob/master/PyYapf.py#L167)

        # use shlex.split because we should honor embedded quoted args
        raw_yapf_location = self.find_yapf()
        try:
            self.popen_args = shlex.split(raw_yapf_location, posix=False)
        except AttributeError:
            self.debug('Failed to shlex.split(%s)', raw_yapf_location)
            self.popen_args = raw_yapf_location

to possibly make it work and give us a better idea of what is going on.