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

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

Open
zachriggle opened this issue Oct 6, 2020 · 1 comment

Comments

@zachriggle
Copy link

zachriggle commented Oct 6, 2020

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!
@zachriggle
Copy link
Author

It looks like this is an underlying issue to the pygments library:

$ head -1 bin/code-audit-asserts
#!/usr/bin/env zsh

$ pygmentize bin/code-audit-asserts
Error: no lexer for filename 'bin/code-audit-asserts' found

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant