Skip to content

Formatting with yapf failed if module file name is 'token.py' #706

Closed
@Tiscs

Description

@Tiscs

Environment data

VS Code version: 1.19.3
Python Extension version: 2018.1.0
Python Version: 3.6.4
OS and version: macOS 10.13.3

Actual behavior

Format module failed when file name is token.py.

Expected behavior

The file will be formatted, no errors in output.

Steps to reproduce:

  • Create a file named token.py;
  • Execute command Format Document in vscode;

Logs

Output from Python output panel

Formatting with yapf failed.
Error: Traceback (most recent call last):
  File "/usr/local/Cellar/python3/3.6.4_2/Frameworks/Python.framework/Versions/3.6/lib/python3.6/runpy.py", line 183, in _run_module_as_main
    mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
  File "/usr/local/Cellar/python3/3.6.4_2/Frameworks/Python.framework/Versions/3.6/lib/python3.6/runpy.py", line 142, in _get_module_details
    return _get_module_details(pkg_main_name, error)
  File "/usr/local/Cellar/python3/3.6.4_2/Frameworks/Python.framework/Versions/3.6/lib/python3.6/runpy.py", line 109, in _get_module_details
    __import__(pkg_name)
  File "/usr/local/lib/python3.6/site-packages/yapf/__init__.py", line 31, in <module>
    import logging
  File "/usr/local/Cellar/python3/3.6.4_2/Frameworks/Python.framework/Versions/3.6/lib/python3.6/logging/__init__.py", line 26, in <module>
    import sys, os, time, io, traceback, warnings, weakref, collections
  File "/usr/local/Cellar/python3/3.6.4_2/Frameworks/Python.framework/Versions/3.6/lib/python3.6/traceback.py", line 5, in <module>
    import linecache
  File "/usr/local/Cellar/python3/3.6.4_2/Frameworks/Python.framework/Versions/3.6/lib/python3.6/linecache.py", line 11, in <module>
    import tokenize
  File "/usr/local/Cellar/python3/3.6.4_2/Frameworks/Python.framework/Versions/3.6/lib/python3.6/tokenize.py", line 35, in <module>
    from token import *
  File "/Users/Tiscs/Projects/auth.py/config/token.py", line 1, in <module>
    from logging import getLogger
ImportError: cannot import name 'getLogger'

Output from Console window (Help->Developer Tools menu)

Nothing

Metadata

Metadata

Labels

area-formattingbugIssue identified by VS Code Team member as probable bug

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions