Pipenv: Pipfile parsing not fully TOML compliant

Created on 1 Mar 2018  路  3Comments  路  Source: pypa/pipenv

This exact concern appears to have been raised and dismissed in issue #613. At some point pipenv dropped proper support for quoted keys. If this is not the case then I'm hopeful I can be pointed to the specification used in order to better construct my Pipfiles.

The paragraphs pertaining to quoted and dotted keys in the Keys section of this README are relevant to this issue: https://github.com/toml-lang/toml#keys

Describe your environment
  1. Debian 10
  2. Python version: 3.6.4
  3. Pipenv version: 10.1.2
Expected result

This Pipfile...

[[source]]
url = "https://pypi.python.org/simple"
verify_ssl = true
name = "pypi"

["requires"]
python_version = "3.6"

[packages]
motor = "*"

    [packages."discord.py"]
    git = "https://github.com/Rapptz/discord.py.git"
    ref = "rewrite"
    editable = true
    extras = ["voice"]

Should render the following dictionary... (parsed by toml and prettyprinted)

{'packages': {'discord.py': {'editable': True,
                             'extras': ['voice'],
                             'git': 'https://github.com/Rapptz/discord.py.git',
                             'ref': 'rewrite'},
              'motor': '*'},
 'requires': {'python_version': '3.6'},
 'source': [{'name': 'pypi',
             'url': 'https://pypi.python.org/simple',
             'verify_ssl': True}]}
Actual result
Traceback (most recent call last):
  File "/home/akirasama/.local/bin/pipenv", line 11, in <module>
    sys.exit(cli())
  File "/home/akirasama/.local/venvs/pipenv/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/home/akirasama/.local/venvs/pipenv/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/home/akirasama/.local/venvs/pipenv/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/akirasama/.local/venvs/pipenv/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/akirasama/.local/venvs/pipenv/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/home/akirasama/.local/venvs/pipenv/lib/python3.6/site-packages/pipenv/vendor/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/akirasama/.local/venvs/pipenv/lib/python3.6/site-packages/pipenv/cli.py", line 433, in sync
    clear=clear, unused=unused, sequential=sequential
  File "/home/akirasama/.local/venvs/pipenv/lib/python3.6/site-packages/pipenv/core.py", line 2389, in do_sync
    ensure_project(three=three, python=python, validate=False)
  File "/home/akirasama/.local/venvs/pipenv/lib/python3.6/site-packages/pipenv/core.py", line 603, in ensure_project
    ensure_virtualenv(three=three, python=python, site_packages=site_packages)
  File "/home/akirasama/.local/venvs/pipenv/lib/python3.6/site-packages/pipenv/core.py", line 548, in ensure_virtualenv
    python = ensure_python(three=three, python=python)
  File "/home/akirasama/.local/venvs/pipenv/lib/python3.6/site-packages/pipenv/core.py", line 424, in ensure_python
    python = project.required_python_version
  File "/home/akirasama/.local/venvs/pipenv/lib/python3.6/site-packages/pipenv/project.py", line 110, in required_python_version
    required = self.parsed_pipfile.get('requires', {}).get('python_full_version')
  File "/home/akirasama/.local/venvs/pipenv/lib/python3.6/site-packages/pipenv/project.py", line 271, in parsed_pipfile
    return contoml.loads(toml.dumps(data, preserve=True))
  File "/home/akirasama/.local/venvs/pipenv/lib/python3.6/site-packages/pipenv/patched/contoml/__init__.py", line 15, in loads
    elements = parse_tokens(tokens)
  File "/home/akirasama/.local/venvs/pipenv/lib/python3.6/site-packages/pipenv/patched/prettytoml/parser/__init__.py", line 17, in parse_tokens
    return _parse_token_stream(TokenStream(tokens))
  File "/home/akirasama/.local/venvs/pipenv/lib/python3.6/site-packages/pipenv/patched/prettytoml/parser/__init__.py", line 32, in _parse_token_stream
    raise ParsingError('Failed to parse line {}'.format(pending.head.row))
prettytoml.parser.errors.ParsingError: Failed to parse line 11
Steps to replicate

$ pipenv lock

Won't Fix

Most helpful comment

I see. The wontfix label had me confused. Thank you!

All 3 comments

@kennethreitz

Would you be able to explain why this portion of the TOML specification won't be supported? I'd really rather not have to resort to inline tables for all of my packages.

Would it be better that I make an issue on the pipfile repository regarding its adherence to the TOML specification?

we'll fix it, it's just low priority for us right now

I see. The wontfix label had me confused. Thank you!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

FooBarQuaxx picture FooBarQuaxx  路  3Comments

jeyraof picture jeyraof  路  3Comments

fbender picture fbender  路  3Comments

leileigong picture leileigong  路  3Comments

erinxocon picture erinxocon  路  3Comments