PyYapf icon indicating copy to clipboard operation
PyYapf copied to clipboard

Formatting gets error: AttributeError: 'NoneType' object has no attribute 'read'

Open qwanzaden opened this issue 1 year ago • 1 comments

On a fresh pip install of yapf, and a fresh sublime install of PyYapf, pressing ctrl+alt+f on a file with this one line of content:

import numpy

with nothing selected generates this error in the sublime text console:

Traceback (most recent call last):
  File "C:\Program Files\Sublime Text 3\Lib\python33\sublime_plugin.py", line 1494, in run_
    return self.run(edit)
  File "C:\Users\Chris Pratt\AppData\Roaming\Sublime Text 3\Installed Packages\PyYapf Python Formatter.sublime-package\PyYapf.py", line 455, in run
  File "C:\Users\Chris Pratt\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'

Following the instructions on this bug ticket to change pyyapf.py inside the directory C:\Users\Chris Pratt\AppData\Roaming\Sublime Text 3\Installed Packages by unzipping then re-zipping the file PyYapf Python Formatter.sublime-package, then restarting sublime text, generates this error instead.

Traceback (most recent call last):
  File "C:\Program Files\Sublime Text 3\Lib\python33\sublime_plugin.py", line 1494, in run_
    return self.run(edit)
  File "C:\Users\Chris Pratt\AppData\Roaming\Sublime Text 3\Installed Packages\PyYapf Python Formatter.sublime-package\PyYapf.py", line 468, in run
  File "C:\Users\Chris Pratt\AppData\Roaming\Sublime Text 3\Installed Packages\PyYapf Python Formatter.sublime-package\PyYapf.py", line 271, in format
  File "./python3.3/subprocess.py", line 819, in __init__
  File "./python3.3/subprocess.py", line 1063, in _execute_child
  File "./python3.3/subprocess.py", line 625, in list2cmdline
TypeError: 'NoneType' object is not iterable

I am on windows 10, sublime text 3 (build 4143), and python 3.7.8.

qwanzaden avatar Apr 14 '23 16:04 qwanzaden

Huh, that is unexpected. I'll see if I can reproduce the problem.

On Fri, Apr 14, 2023 at 9:19 AM Chris Pratt @.***> wrote:

On a fresh pip install of yapf, and a fresh sublime install of PyYapf, pressing ctrl+alt+f on this file with nothing selected

import numpy

generates this error

Traceback (most recent call last): File "C:\Program Files\Sublime Text 3\Lib\python33\sublime_plugin.py", line 1494, in run_ return self.run(edit) File "C:\Users\Chris Pratt\AppData\Roaming\Sublime Text 3\Installed Packages\PyYapf Python Formatter.sublime-package\PyYapf.py", line 455, in run File "C:\Users\Chris Pratt\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'

— Reply to this email directly, view it on GitHub https://github.com/jason-kane/PyYapf/issues/57, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAORY6GRCP4PFKCJQWLPJLTXBF2IRANCNFSM6AAAAAAW6T3G3Y . You are receiving this because you are subscribed to this thread.Message ID: @.***>

jason-kane avatar Apr 14 '23 18:04 jason-kane