Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ERROR: Unrecoverable exception thrown when parsing scripts/create_fake_crack_developing_movie_test.py! This should NEVER happen. #1592

Closed
MasaYan24 opened this issue Nov 3, 2020 · 3 comments
Labels
help wanted Extra attention is needed
Milestone

Comments

@MasaYan24
Copy link

ERROR: Unrecoverable exception thrown when parsing scripts/create_fake_crack_developing_movie_test.py! This should NEVER happen.
If encountered, please open an issue: https://github.com/PyCQA/isort/issues/new
Traceback (most recent call last):
  File "/home/takahashi/.cache/pypoetry/virtualenvs/pj-04JfRiLX-py3.6/bin/isort", line 8, in <module>
    sys.exit(main())
  File "/home/takahashi/.cache/pypoetry/virtualenvs/pj-04JfRiLX-py3.6/lib/python3.6/site-packages/isort/main.py", line 953, in main
    for sort_attempt in attempt_iterator:
  File "/home/takahashi/.cache/pypoetry/virtualenvs/pj-04JfRiLX-py3.6/lib/python3.6/site-packages/isort/main.py", line 947, in <genexpr>
    for file_name in file_names
  File "/home/takahashi/.cache/pypoetry/virtualenvs/pj-04JfRiLX-py3.6/lib/python3.6/site-packages/isort/main.py", line 100, in sort_imports
    **kwargs,
  File "/home/takahashi/.cache/pypoetry/virtualenvs/pj-04JfRiLX-py3.6/lib/python3.6/site-packages/isort/api.py", line 303, in sort_file
    with io.File.read(filename) as source_file:
AttributeError: type object 'File' has no attribute 'read'
@timothycrosley
Copy link
Member

Hi @MasaYan24,

Thank you for reporting! Would you by any chance be willing to provide some additional context:

What version of isort are you using (isort -V)?
What does your configuration look like (isort . --show-config)?
What command are you using to run isort?

Thanks!

~Timothy

@MasaYan24
Copy link
Author

MasaYan24 commented Nov 6, 2020

@timothycrosley
Thank you.
Let me answer to your comment:

What version of isort are you using (isort -V)?

5.6.4

What does your configuration look like (isort . --show-config)?

{
    "_known_patterns": null,
    "_section_comments": null,
    "py_version": "py3",
    "force_to_top": [],
    "skip": [
        "rules",
        "bazel-*",
        "node_modules"
    ],
    "skip_glob": [],
    "skip_gitignore": false,
    "line_length": 119,
    "wrap_length": 0,
    "line_ending": "",
    "sections": [
        "FUTURE",
        "STDLIB",
        "THIRDPARTY",
        "FIRSTPARTY",
        "LOCALFOLDER"
    ],
    "no_sections": false,
    "known_future_library": [
        "__future__"
    ],
    "known_third_party": [],
    "known_first_party": [
        "hoge",
        "experimental",
        "converter",
        "hoga"
    ],
    "known_local_folder": [],
    "known_standard_library": [
        "poplib",
        "io",
        "msilib",
        "msvcrt",
        "uu",
        "posix",
        "socketserver",
        "cProfile",
        "rlcompleter",
        "dummy_threading",
        "asynchat",
        "plistlib",
        "zlib",
        "filecmp",
        "copyreg",
        "sre_constants",
        "telnetlib",
        "shelve",
        "pstats",
        "pathlib",
        "builtins",
        "chunk",
        "xml",
        "sre_parse",
        "asyncore",
        "asyncio",
        "macpath",
        "re",
        "grp",
        "numbers",
        "argparse",
        "copy",
        "binascii",
        "codecs",
        "enum",
        "venv",
        "sys",
        "lzma",
        "getopt",
        "mimetypes",
        "binhex",
        "pprint",
        "posixpath",
        "locale",
        "mmap",
        "turtle",
        "itertools",
        "netrc",
        "contextlib",
        "sqlite3",
        "logging",
        "configparser",
        "hmac",
        "nis",
        "crypt",
        "ntpath",
        "dis",
        "aifc",
        "queue",
        "textwrap",
        "timeit",
        "bz2",
        "unicodedata",
        "typing",
        "ossaudiodev",
        "tty",
        "importlib",
        "smtpd",
        "tkinter",
        "zipimport",
        "pydoc",
        "selectors",
        "cgitb",
        "compileall",
        "distutils",
        "ast",
        "_dummy_thread",
        "_thread",
        "cmd",
        "fcntl",
        "graphlib",
        "reprlib",
        "heapq",
        "struct",
        "token",
        "runpy",
        "winreg",
        "random",
        "zipapp",
        "glob",
        "math",
        "readline",
        "nntplib",
        "tempfile",
        "stat",
        "turtledemo",
        "uuid",
        "doctest",
        "difflib",
        "shlex",
        "errno",
        "zoneinfo",
        "pwd",
        "pty",
        "multiprocessing",
        "tabnanny",
        "formatter",
        "threading",
        "concurrent",
        "hashlib",
        "py_compile",
        "wave",
        "codeop",
        "pickle",
        "spwd",
        "types",
        "gc",
        "secrets",
        "abc",
        "ensurepip",
        "colorsys",
        "email",
        "fractions",
        "tracemalloc",
        "xdrlib",
        "tokenize",
        "collections",
        "sre",
        "site",
        "symtable",
        "imaplib",
        "stringprep",
        "modulefinder",
        "linecache",
        "html",
        "pdb",
        "traceback",
        "contextvars",
        "cgi",
        "pyclbr",
        "time",
        "audioop",
        "encodings",
        "base64",
        "array",
        "quopri",
        "urllib",
        "trace",
        "pipes",
        "xmlrpc",
        "wsgiref",
        "select",
        "code",
        "gettext",
        "unittest",
        "sched",
        "imghdr",
        "shutil",
        "gzip",
        "mailcap",
        "calendar",
        "csv",
        "termios",
        "winsound",
        "ftplib",
        "os",
        "sysconfig",
        "tarfile",
        "functools",
        "marshal",
        "resource",
        "socket",
        "statistics",
        "syslog",
        "sre_compile",
        "mailbox",
        "curses",
        "ctypes",
        "signal",
        "pickletools",
        "bisect",
        "getpass",
        "profile",
        "atexit",
        "fileinput",
        "parser",
        "operator",
        "subprocess",
        "fnmatch",
        "webbrowser",
        "pkgutil",
        "warnings",
        "symbol",
        "platform",
        "sunau",
        "cmath",
        "datetime",
        "smtplib",
        "string",
        "keyword",
        "ssl",
        "dataclasses",
        "test",
        "ipaddress",
        "fpectl",
        "faulthandler",
        "inspect",
        "decimal",
        "sndhdr",
        "imp",
        "dbm",
        "zipfile",
        "lib2to3",
        "http",
        "json",
        "weakref",
        "bdb",
        "optparse"
    ],
    "extra_standard_library": [],
    "known_other": {},
    "multi_line_output": "VERTICAL_HANGING_INDENT",
    "forced_separate": [],
    "indent": "    ",
    "comment_prefix": "  #",
    "length_sort": false,
    "length_sort_straight": false,
    "length_sort_sections": [],
    "add_imports": [],
    "remove_imports": [],
    "append_only": false,
    "reverse_relative": false,
    "force_single_line": false,
    "single_line_exclusions": [
        "typing"
    ],
    "default_section": "THIRDPARTY",
    "import_headings": {},
    "balanced_wrapping": false,
    "use_parentheses": true,
    "order_by_type": true,
    "atomic": false,
    "lines_after_imports": -1,
    "lines_between_sections": 1,
    "lines_between_types": 0,
    "combine_as_imports": false,
    "combine_star": false,
    "include_trailing_comma": true,
    "from_first": false,
    "verbose": false,
    "quiet": false,
    "force_adds": false,
    "force_alphabetical_sort_within_sections": true,
    "force_alphabetical_sort": false,
    "force_grid_wrap": 0,
    "force_sort_within_sections": true,
    "lexicographical": true,
    "group_by_package": false,
    "ignore_whitespace": false,
    "no_lines_before": [],
    "no_inline_sort": false,
    "ignore_comments": false,
    "case_sensitive": false,
    "sources": [
        {
            "py_version": "py3",
            "force_to_top": [],
            "skip": [
                ".mypy_cache",
                ".direnv",
                ".eggs",
                ".hg",
                ".nox",
                ".svn",
                "buck-out",
                "venv",
                ".bzr",
                ".git",
                "_build",
                ".tox",
                ".pants.d",
                "dist",
                "build",
                "node_modules",
                ".venv"
            ],
            "skip_glob": [],
            "skip_gitignore": false,
            "line_length": 79,
            "wrap_length": 0,
            "line_ending": "",
            "sections": [
                "FUTURE",
                "STDLIB",
                "THIRDPARTY",
                "FIRSTPARTY",
                "LOCALFOLDER"
            ],
            "no_sections": false,
            "known_future_library": [
                "__future__"
            ],
            "known_third_party": [],
            "known_first_party": [],
            "known_local_folder": [],
            "known_standard_library": [
                "poplib",
                "io",
                "msilib",
                "msvcrt",
                "uu",
                "posix",
                "socketserver",
                "cProfile",
                "rlcompleter",
                "dummy_threading",
                "asynchat",
                "plistlib",
                "zlib",
                "filecmp",
                "copyreg",
                "sre_constants",
                "telnetlib",
                "shelve",
                "pstats",
                "pathlib",
                "builtins",
                "chunk",
                "xml",
                "sre_parse",
                "asyncore",
                "asyncio",
                "macpath",
                "re",
                "grp",
                "numbers",
                "argparse",
                "copy",
                "binascii",
                "codecs",
                "enum",
                "venv",
                "sys",
                "lzma",
                "getopt",
                "mimetypes",
                "binhex",
                "pprint",
                "posixpath",
                "locale",
                "mmap",
                "turtle",
                "itertools",
                "netrc",
                "contextlib",
                "sqlite3",
                "logging",
                "configparser",
                "hmac",
                "nis",
                "crypt",
                "ntpath",
                "dis",
                "aifc",
                "queue",
                "textwrap",
                "timeit",
                "bz2",
                "unicodedata",
                "typing",
                "ossaudiodev",
                "tty",
                "importlib",
                "smtpd",
                "tkinter",
                "zipimport",
                "pydoc",
                "selectors",
                "cgitb",
                "compileall",
                "distutils",
                "ast",
                "_dummy_thread",
                "_thread",
                "cmd",
                "fcntl",
                "graphlib",
                "reprlib",
                "heapq",
                "struct",
                "token",
                "runpy",
                "winreg",
                "random",
                "zipapp",
                "glob",
                "math",
                "readline",
                "nntplib",
                "tempfile",
                "stat",
                "turtledemo",
                "uuid",
                "doctest",
                "difflib",
                "shlex",
                "errno",
                "zoneinfo",
                "pwd",
                "pty",
                "multiprocessing",
                "tabnanny",
                "formatter",
                "threading",
                "concurrent",
                "hashlib",
                "py_compile",
                "wave",
                "codeop",
                "pickle",
                "spwd",
                "types",
                "gc",
                "secrets",
                "abc",
                "ensurepip",
                "colorsys",
                "email",
                "fractions",
                "tracemalloc",
                "xdrlib",
                "tokenize",
                "collections",
                "sre",
                "site",
                "symtable",
                "imaplib",
                "stringprep",
                "modulefinder",
                "linecache",
                "html",
                "pdb",
                "traceback",
                "contextvars",
                "cgi",
                "pyclbr",
                "time",
                "audioop",
                "encodings",
                "base64",
                "array",
                "quopri",
                "urllib",
                "trace",
                "pipes",
                "xmlrpc",
                "wsgiref",
                "select",
                "code",
                "gettext",
                "unittest",
                "sched",
                "imghdr",
                "shutil",
                "gzip",
                "mailcap",
                "calendar",
                "csv",
                "termios",
                "winsound",
                "ftplib",
                "os",
                "sysconfig",
                "tarfile",
                "functools",
                "marshal",
                "resource",
                "socket",
                "statistics",
                "syslog",
                "sre_compile",
                "mailbox",
                "curses",
                "ctypes",
                "signal",
                "pickletools",
                "bisect",
                "getpass",
                "profile",
                "atexit",
                "fileinput",
                "parser",
                "operator",
                "subprocess",
                "fnmatch",
                "webbrowser",
                "pkgutil",
                "warnings",
                "symbol",
                "platform",
                "sunau",
                "cmath",
                "datetime",
                "smtplib",
                "string",
                "keyword",
                "ssl",
                "dataclasses",
                "test",
                "ipaddress",
                "fpectl",
                "faulthandler",
                "inspect",
                "decimal",
                "sndhdr",
                "imp",
                "dbm",
                "zipfile",
                "lib2to3",
                "http",
                "json",
                "weakref",
                "bdb",
                "optparse"
            ],
            "extra_standard_library": [],
            "known_other": {},
            "multi_line_output": "GRID",
            "forced_separate": [],
            "indent": "    ",
            "comment_prefix": "  #",
            "length_sort": false,
            "length_sort_straight": false,
            "length_sort_sections": [],
            "add_imports": [],
            "remove_imports": [],
            "append_only": false,
            "reverse_relative": false,
            "force_single_line": false,
            "single_line_exclusions": [],
            "default_section": "THIRDPARTY",
            "import_headings": {},
            "balanced_wrapping": false,
            "use_parentheses": false,
            "order_by_type": true,
            "atomic": false,
            "lines_after_imports": -1,
            "lines_between_sections": 1,
            "lines_between_types": 0,
            "combine_as_imports": false,
            "combine_star": false,
            "include_trailing_comma": false,
            "from_first": false,
            "verbose": false,
            "quiet": false,
            "force_adds": false,
            "force_alphabetical_sort_within_sections": false,
            "force_alphabetical_sort": false,
            "force_grid_wrap": 0,
            "force_sort_within_sections": false,
            "lexicographical": false,
            "group_by_package": false,
            "ignore_whitespace": false,
            "no_lines_before": [],
            "no_inline_sort": false,
            "ignore_comments": false,
            "case_sensitive": false,
            "sources": [],
            "virtual_env": "",
            "conda_env": "",
            "ensure_newline_before_comments": false,
            "directory": "",
            "profile": "",
            "honor_noqa": false,
            "src_paths": [],
            "old_finders": false,
            "remove_redundant_aliases": false,
            "float_to_top": false,
            "filter_files": false,
            "formatter": "",
            "formatting_function": null,
            "color_output": false,
            "treat_comments_as_code": [],
            "treat_all_comments_as_code": false,
            "supported_extensions": [
                "pxd",
                "pyx",
                "pyi",
                "py"
            ],
            "blocked_extensions": [
                "pex"
            ],
            "constants": [],
            "classes": [],
            "variables": [],
            "dedup_headings": false,
            "only_sections": false,
            "only_modified": false,
            "auto_identify_namespace_packages": true,
            "namespace_packages": [],
            "source": "defaults"
        },
        {
            "lexicographical": true,
            "force_sort_within_sections": true,
            "force_alphabetical_sort_within_sections": true,
            "include_trailing_comma": true,
            "multi_line_output": "VERTICAL_HANGING_INDENT",
            "use_parentheses": true,
            "known_first_party": [
                "hoge",
                "experimental",
                "converter",
                "hoga"
            ],
            "line_length": 119,
            "single_line_exclusions": [
                "typing"
            ],
            "skip": [
                "rules",
                "bazel-*",
                "node_modules"
            ],
            "source": "/home/user-hogehoge/mono/pyproject.toml"
        }
    ],
    "virtual_env": "",
    "conda_env": "",
    "ensure_newline_before_comments": false,
    "directory": "/home/user-hogehoge/mono",
    "profile": "",
    "honor_noqa": false,
    "src_paths": [
        "/home/user-hogehoge/mono/src",
        "/home/user-hogehoge/mono"
    ],
    "old_finders": false,
    "remove_redundant_aliases": false,
    "float_to_top": false,
    "filter_files": false,
    "formatter": "",
    "formatting_function": null,
    "color_output": false,
    "treat_comments_as_code": [],
    "treat_all_comments_as_code": false,
    "supported_extensions": [
        "pxd",
        "pyx",
        "pyi",
        "py"
    ],
    "blocked_extensions": [
        "pex"
    ],
    "constants": [],
    "classes": [],
    "variables": [],
    "dedup_headings": false,
    "only_sections": false,
    "only_modified": false,
    "auto_identify_namespace_packages": true,
    "namespace_packages": []
}

What command are you using to run isort?

I tried something like

isort /path/to/file

pyproject.toml is something like

[tool.black]
line-length = 120
target-version = ['py36']
exclude = '(\.tpl\.py|rules)'

[tool.isort]
lexicographical = true
force_sort_within_sections = true
force_alphabetical_sort_within_sections = true
include_trailing_comma = true
multi_line_output = 3
use_parentheses = true
known_first_party = "hoga,converter,experimental,hoge"
line_length = 119
single_line_exclusions = ["typing"]
skip = ["bazel-*", "rules", "node_modules"]

@timothycrosley
Copy link
Member

Thank you for reporting! After investigation I was able to confirm this issue is a reflection of a bug in early patch release of Python3.6 (the latest 3.6.12 does not have the error) with staticmethods on a NamedTuple class. This is fixed in develop and will be released with the next minor release of isort.

Thanks!

~Timothy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants