Skip to content

Commit

Permalink
update patch
Browse files Browse the repository at this point in the history
  • Loading branch information
frostming committed Nov 10, 2018
1 parent 6df7d88 commit 88ad74c
Show file tree
Hide file tree
Showing 12 changed files with 157 additions and 193 deletions.
7 changes: 1 addition & 6 deletions pipenv/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,19 +102,14 @@ def convert_toml_outline_tables(parsed):
else:
empty_inline_table = toml.TomlDecoder().get_empty_inline_table
for section in ("packages", "dev-packages"):
has_outline_table = False
table_data = parsed.get(section, {}).copy()
table_data = parsed.get(section, {})
for package, value in table_data.items():
if hasattr(value, "keys") and not isinstance(
value, (tomlkit.items.InlineTable, toml.decoder.InlineTableDict)
):
has_outline_table = True
table = empty_inline_table()
table.update(value)
table_data[package] = table
if has_outline_table:
# We'll lose comments here, only update when necessary
parsed[section] = table_data
return parsed


Expand Down
2 changes: 0 additions & 2 deletions pipenv/vendor/tomlkit/api.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import datetime as _datetime

from typing import Tuple

from ._utils import parse_rfc3339
from .container import Container
from .items import AoT
Expand Down
16 changes: 7 additions & 9 deletions pipenv/vendor/tomlkit/container.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
from __future__ import unicode_literals

from typing import Any
from typing import Dict
from typing import Generator
from typing import List
from typing import Optional
from typing import Tuple
from typing import Union

from ._compat import decode
from .exceptions import KeyAlreadyPresent
from .exceptions import NonExistentKey
Expand All @@ -17,6 +9,7 @@
from .items import Key
from .items import Null
from .items import Table
from .items import Trivia
from .items import Whitespace
from .items import item as _item

Expand Down Expand Up @@ -221,7 +214,12 @@ def remove(self, key): # type: (Union[Key, str]) -> Container
for i in idx:
self._body[i] = (None, Null())
else:
self._body[idx] = (None, Null())
old_data = self._body[idx]
trivia = getattr(old_data, "trivia", None)
if trivia and trivia.comment:
self._body[idx] = (None, Comment(Trivia(comment_ws="", comment=trivia.comment)))
else:
self._body[idx] = (None, Null())

super(Container, self).__delitem__(key.key)

Expand Down
2 changes: 0 additions & 2 deletions pipenv/vendor/tomlkit/exceptions.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from typing import Optional


class TOMLKitError(Exception):

Expand Down
13 changes: 5 additions & 8 deletions pipenv/vendor/tomlkit/items.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,6 @@
from datetime import datetime
from datetime import time
from enum import Enum
from typing import Any
from typing import Dict
from typing import Generator
from typing import List
from typing import Optional
from typing import Union


from ._compat import PY2
from ._compat import decode
Expand All @@ -25,6 +18,7 @@
from pipenv.vendor.backports.functools_lru_cache import lru_cache
else:
from functools import lru_cache
from toml.decoder import InlineTableDict


def item(value, _parent=None):
Expand All @@ -40,7 +34,10 @@ def item(value, _parent=None):
elif isinstance(value, float):
return Float(value, Trivia(), str(value))
elif isinstance(value, dict):
val = Table(Container(), Trivia(), False)
if isinstance(value, InlineTableDict):
val = InlineTable(Container(), Trivia())
else:
val = Table(Container(), Trivia(), False)
for k, v in sorted(value.items(), key=lambda i: (isinstance(i[1], dict), i[0])):
val[k] = item(v, _parent=val)

Expand Down
7 changes: 0 additions & 7 deletions pipenv/vendor/tomlkit/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,6 @@
import re
import string

from typing import Any
from typing import Generator
from typing import List
from typing import Optional
from typing import Tuple
from typing import Union

from ._compat import chr
from ._compat import decode
from ._utils import _escaped
Expand Down
2 changes: 0 additions & 2 deletions pipenv/vendor/tomlkit/source.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
import itertools

from copy import copy
from typing import Optional
from typing import Tuple

from ._compat import PY2
from ._compat import unicode
Expand Down
3 changes: 0 additions & 3 deletions pipenv/vendor/tomlkit/toml_file.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import io

from typing import Any
from typing import Dict

from .api import loads
from .toml_document import TOMLDocument

Expand Down
34 changes: 0 additions & 34 deletions tasks/vendoring/patches/vendor/tomlkit-dump-inline-table.patch

This file was deleted.

144 changes: 144 additions & 0 deletions tasks/vendoring/patches/vendor/tomlkit-fix.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
diff --git a/pipenv/vendor/tomlkit/api.py b/pipenv/vendor/tomlkit/api.py
index e541c20c..0ac26752 100644
--- a/pipenv/vendor/tomlkit/api.py
+++ b/pipenv/vendor/tomlkit/api.py
@@ -1,7 +1,5 @@
import datetime as _datetime

-from typing import Tuple
-
from ._utils import parse_rfc3339
from .container import Container
from .items import AoT
diff --git a/pipenv/vendor/tomlkit/container.py b/pipenv/vendor/tomlkit/container.py
index cb8af1d5..56ee2d62 100644
--- a/pipenv/vendor/tomlkit/container.py
+++ b/pipenv/vendor/tomlkit/container.py
@@ -1,13 +1,5 @@
from __future__ import unicode_literals

-from typing import Any
-from typing import Dict
-from typing import Generator
-from typing import List
-from typing import Optional
-from typing import Tuple
-from typing import Union
-
from ._compat import decode
from .exceptions import KeyAlreadyPresent
from .exceptions import NonExistentKey
@@ -17,6 +9,7 @@ from .items import Item
from .items import Key
from .items import Null
from .items import Table
+from .items import Trivia
from .items import Whitespace
from .items import item as _item

@@ -221,7 +214,12 @@ class Container(dict):
for i in idx:
self._body[i] = (None, Null())
else:
- self._body[idx] = (None, Null())
+ old_data = self._body[idx]
+ trivia = getattr(old_data, "trivia", None)
+ if trivia and trivia.comment:
+ self._body[idx] = (None, Comment(Trivia(comment_ws="", comment=trivia.comment)))
+ else:
+ self._body[idx] = (None, Null())

super(Container, self).__delitem__(key.key)

diff --git a/pipenv/vendor/tomlkit/exceptions.py b/pipenv/vendor/tomlkit/exceptions.py
index 4fbc667b..c1a4e620 100644
--- a/pipenv/vendor/tomlkit/exceptions.py
+++ b/pipenv/vendor/tomlkit/exceptions.py
@@ -1,5 +1,3 @@
-from typing import Optional
-

class TOMLKitError(Exception):

diff --git a/pipenv/vendor/tomlkit/items.py b/pipenv/vendor/tomlkit/items.py
index 375b5f02..7035b69e 100644
--- a/pipenv/vendor/tomlkit/items.py
+++ b/pipenv/vendor/tomlkit/items.py
@@ -7,13 +7,6 @@ from datetime import date
from datetime import datetime
from datetime import time
from enum import Enum
-from typing import Any
-from typing import Dict
-from typing import Generator
-from typing import List
-from typing import Optional
-from typing import Union
-

from ._compat import PY2
from ._compat import decode
@@ -25,6 +18,7 @@ if PY2:
from pipenv.vendor.backports.functools_lru_cache import lru_cache
else:
from functools import lru_cache
+from toml.decoder import InlineTableDict


def item(value, _parent=None):
@@ -40,7 +34,10 @@ def item(value, _parent=None):
elif isinstance(value, float):
return Float(value, Trivia(), str(value))
elif isinstance(value, dict):
- val = Table(Container(), Trivia(), False)
+ if isinstance(value, InlineTableDict):
+ val = InlineTable(Container(), Trivia())
+ else:
+ val = Table(Container(), Trivia(), False)
for k, v in sorted(value.items(), key=lambda i: (isinstance(i[1], dict), i[0])):
val[k] = item(v, _parent=val)

diff --git a/pipenv/vendor/tomlkit/parser.py b/pipenv/vendor/tomlkit/parser.py
index 7b948331..3f507bb4 100644
--- a/pipenv/vendor/tomlkit/parser.py
+++ b/pipenv/vendor/tomlkit/parser.py
@@ -4,13 +4,6 @@ from __future__ import unicode_literals
import re
import string

-from typing import Any
-from typing import Generator
-from typing import List
-from typing import Optional
-from typing import Tuple
-from typing import Union
-
from ._compat import chr
from ._compat import decode
from ._utils import _escaped
diff --git a/pipenv/vendor/tomlkit/source.py b/pipenv/vendor/tomlkit/source.py
index 1a96e058..dcfdafd0 100644
--- a/pipenv/vendor/tomlkit/source.py
+++ b/pipenv/vendor/tomlkit/source.py
@@ -4,8 +4,6 @@ from __future__ import unicode_literals
import itertools

from copy import copy
-from typing import Optional
-from typing import Tuple

from ._compat import PY2
from ._compat import unicode
diff --git a/pipenv/vendor/tomlkit/toml_file.py b/pipenv/vendor/tomlkit/toml_file.py
index 3b416664..631e9959 100644
--- a/pipenv/vendor/tomlkit/toml_file.py
+++ b/pipenv/vendor/tomlkit/toml_file.py
@@ -1,8 +1,5 @@
import io

-from typing import Any
-from typing import Dict
-
from .api import loads
from .toml_document import TOMLDocument

Loading

0 comments on commit 88ad74c

Please sign in to comment.