Skip to content

Pycco is unable to determine syntax for a Python3-formatted file without an appropriate extension #117

@zachriggle

Description

@zachriggle

When running pycco file, it works well when the file is named foo.py, but does not work for foo despite having a shebang.

Example Script

Create this file as example. Note that if it is named example.py, everything works as expected.

#!/usr/bin/env python3
import os

class CommandLineFlag(object):
    '''Holds information about a command-line argument'''

Pycco Output

$ pycco example
Traceback (most recent call last):
  File "/Users/zachriggle/Library/Python/3.8/lib/python/site-packages/pycco/main.py", line 397, in get_language
    raise ValueError()
ValueError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/zachriggle/Library/Python/3.8/bin/pycco", line 10, in <module>
    sys.exit(main())
  File "/Users/zachriggle/Library/Python/3.8/lib/python/site-packages/pycco/main.py", line 629, in main
    process(args.sources, outdir=outdir, preserve_paths=args.paths,
  File "/Users/zachriggle/Library/Python/3.8/lib/python/site-packages/pycco/main.py", line 533, in process
    next_file()
  File "/Users/zachriggle/Library/Python/3.8/lib/python/site-packages/pycco/main.py", line 518, in next_file
    f.write(generate_documentation(s, preserve_paths=preserve_paths,
  File "/Users/zachriggle/Library/Python/3.8/lib/python/site-packages/pycco/main.py", line 80, in generate_documentation
    return _generate_documentation(source, code, outdir, preserve_paths, language)
  File "/Users/zachriggle/Library/Python/3.8/lib/python/site-packages/pycco/main.py", line 87, in _generate_documentation
    language = get_language(file_path, code, language_name=language)
  File "/Users/zachriggle/Library/Python/3.8/lib/python/site-packages/pycco/main.py", line 402, in get_language
    raise ValueError("Can't figure out the language!")
ValueError: Can't figure out the language!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions