Skip to content

Black produces invalid code with commented out multi-line includes #671

@schrockn

Description

@schrockn

Howdy! Sorry you're having trouble. To expedite your experience,
provide some basics for me:

Operating system: MacOS
Python version: Python 3.7.1
Black version: 18.9b0
Does also happen on master: Yes

repro:

(black-repro) [schrockn@mbp ~/code/playground/black_bug_repro]$ black test.py
error: cannot format test.py: INTERNAL ERROR: Black produced invalid code: invalid syntax (<unknown>, line 11). Please report a bug on https://github.com/ambv/black/issues.  This invalid output might be helpful: /var/folders/nb/18_t4vkx595_cnpf8nz5gt_80000gn/T/blk_di3puv3v.log
All done! 💥 💔 💥
1 file failed to reformat.

test file:

from .config import (
    Any,
    Bool,
    ConfigType,
    ConfigTypeAttributes,
    Int,
    Path,
    #  String,
    #  resolve_to_config_type,
    #  DEFAULT_TYPE_ATTRIBUTES,
)

The invalid output:

(black-repro) [schrockn@mbp ~/code/playground/black_bug_repro]$ more /var/folders/nb/18_t4vkx595_cnpf8nz5gt_80000gn/T/blk_di3puv3v.log
  File "/Users/schrockn/code/githubs/black/black.py", line 3318, in assert_equivalent
    dst_ast = ast.parse(dst)
  File "/Users/schrockn/.pyenv/versions/3.7.1/lib/python3.7/ast.py", line 35, in parse
    return compile(source, filename, mode, PyCF_ONLY_AST)
from .config import (
    Any,
    Bool,
    ConfigType,
    ConfigTypeAttributes,
    Int,
    Path,
    #  String,
    #  resolve_to_config_type,
    #  DEFAULT_TYPE_ATTRIBUTES,
    ,
)

Thanks!

Metadata

Metadata

Assignees

Labels

C: invalid codeBlack destroyed a valid Python fileT: bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions