-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Update Pipenv to 2018.10.9 #696
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
1bc8226
Update Pipenv to 2018.10.9
greysteil 9b7fd56
Update python version warning detection for Pipenv 2018.10.9
greysteil 5193f65
Switch hard name Pipenv spec to pending
greysteil d942b56
Add TOML converter
greysteil 30b5ce9
Clean up and test TomlConverter module
greysteil File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
pip==18.1 | ||
pip-tools==3.1.0 | ||
hashin==0.13.4 | ||
pipenv==2018.7.1 | ||
pipenv==2018.10.9 | ||
pipfile==0.0.2 | ||
poetry==0.11.5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# frozen_string_literal: true | ||
|
||
# This module provides a (hopefully temporary) way to convert outline tables | ||
# generated from dumping TomlRB into inline tables which are understood by | ||
# Pipenv. | ||
# | ||
# This is required because Pipenv doesn't currently support outline tables. | ||
# We have an issue open for that: https://github.com/pypa/pipenv/issues/2960 | ||
module TomlConverter | ||
PIPENV_OUTLINE_TABLES_REGEX = / | ||
\[(?<type>(dev-)?packages)\.(?<name>[^\]]+)\] | ||
(?<content>.*?)(?=^\[|\z) | ||
/mx | ||
|
||
def self.convert_pipenv_outline_tables(content) | ||
# First, find any outline tables that appear in the Pipfile | ||
matches = [] | ||
content.scan(PIPENV_OUTLINE_TABLES_REGEX) { matches << Regexp.last_match } | ||
|
||
# Next, remove all of them. We'll add them back in as inline tables next | ||
updated_content = content.gsub(PIPENV_OUTLINE_TABLES_REGEX, "") | ||
|
||
# Iterate through each of the outline tables we found, adding it back to the | ||
# Pipfile as an inline table | ||
matches.each do |match| | ||
# If the heading for this section doesn't yet exist in the Pipfile, add it | ||
unless updated_content.include?(match[:type]) | ||
updated_content += "\n\n[#{match[:type]}]\n" | ||
end | ||
|
||
# Build the inline table contents from the contents of the outline table | ||
inline_content = match[:content].strip.gsub(/\s*\n+/, ", ") | ||
content_to_insert = "#{match[:name]} = {#{inline_content}}" | ||
|
||
# Insert the created inline table just below the heading for the correct | ||
# section | ||
updated_content.sub!( | ||
"[#{match[:type]}]\n", | ||
"[#{match[:type]}]\n#{content_to_insert}\n" | ||
) | ||
end | ||
|
||
# Return the updated content | ||
updated_content | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
# frozen_string_literal: true | ||
|
||
require "spec_helper" | ||
require "toml_converter" | ||
|
||
describe TomlConverter do | ||
describe ".convert_pipenv_outline_tables" do | ||
subject(:updated_content) do | ||
described_class.convert_pipenv_outline_tables(content) | ||
end | ||
|
||
context "without any outline tables" do | ||
let(:content) { fixture("python", "pipfiles", "exact_version") } | ||
it { is_expected.to eq(content) } | ||
end | ||
|
||
context "without an outline table in the middle of the file" do | ||
let(:content) do | ||
<<~HEREDOC | ||
[[source]] | ||
name = "pypi" | ||
url = "https://pypi.python.org/simple/" | ||
verify_ssl = true | ||
|
||
[packages] | ||
flask = "==1.0.1" | ||
|
||
[packages.raven] | ||
extras = ["flask"] | ||
version = ">= 5.27.1, <= 7.0.0" | ||
|
||
[requires] | ||
python_version = "2.7" | ||
HEREDOC | ||
end | ||
|
||
it "converts the outline table to an inline table" do | ||
expect(updated_content).to eq( | ||
<<~HEREDOC | ||
[[source]] | ||
name = "pypi" | ||
url = "https://pypi.python.org/simple/" | ||
verify_ssl = true | ||
|
||
[packages] | ||
raven = {extras = ["flask"], version = ">= 5.27.1, <= 7.0.0"} | ||
flask = "==1.0.1" | ||
|
||
[requires] | ||
python_version = "2.7" | ||
HEREDOC | ||
) | ||
end | ||
end | ||
|
||
context "without an outline table at the end of the file" do | ||
let(:content) do | ||
<<~HEREDOC | ||
[[source]] | ||
name = "pypi" | ||
url = "https://pypi.python.org/simple/" | ||
verify_ssl = true | ||
|
||
[packages] | ||
flask = "==1.0.1" | ||
|
||
[requires] | ||
python_version = "2.7" | ||
|
||
[packages.raven] | ||
extras = ["flask"] | ||
version = ">= 5.27.1, <= 7.0.0" | ||
HEREDOC | ||
end | ||
|
||
it "converts the outline table to an inline table" do | ||
expect(updated_content).to eq( | ||
<<~HEREDOC | ||
[[source]] | ||
name = "pypi" | ||
url = "https://pypi.python.org/simple/" | ||
verify_ssl = true | ||
|
||
[packages] | ||
raven = {extras = ["flask"], version = ">= 5.27.1, <= 7.0.0"} | ||
flask = "==1.0.1" | ||
|
||
[requires] | ||
python_version = "2.7" | ||
|
||
HEREDOC | ||
) | ||
end | ||
end | ||
|
||
context "without an outline table for a dev-package" do | ||
let(:content) do | ||
<<~HEREDOC | ||
[[source]] | ||
name = "pypi" | ||
url = "https://pypi.python.org/simple/" | ||
verify_ssl = true | ||
|
||
[packages] | ||
flask = "==1.0.1" | ||
|
||
[dev-packages.raven] | ||
extras = ["flask"] | ||
version = ">= 5.27.1, <= 7.0.0" | ||
|
||
[requires] | ||
python_version = "2.7" | ||
HEREDOC | ||
end | ||
|
||
it "converts the outline table to an inline table" do | ||
expect(updated_content).to eq( | ||
<<~HEREDOC | ||
[[source]] | ||
name = "pypi" | ||
url = "https://pypi.python.org/simple/" | ||
verify_ssl = true | ||
|
||
[packages] | ||
flask = "==1.0.1" | ||
|
||
[requires] | ||
python_version = "2.7" | ||
|
||
|
||
[dev-packages] | ||
raven = {extras = ["flask"], version = ">= 5.27.1, <= 7.0.0"} | ||
HEREDOC | ||
) | ||
end | ||
end | ||
end | ||
end |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suddenly, it introduces more bugs than you can expect 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Haha, yeah, that's definitely a danger...! 😉