prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  don't rely on master branch for latest version number
  ## Feature
  
  ### Feature description
  The `master` branch of dbt isn't really a thing anymore. Instead of relying on the [master](https://github.com/fishtown-analytics/dbt/blob/51f68e3aabcda57afbe5051983d1d17e092be665/dbt/version.py#L12) branch to grab the latest release number, we should pull it from PyPi.
  
  We can use [this api](https://warehouse.readthedocs.io/api-reference/json/) to fetch [some JSON info](https://pypi.org/pypi/dbt/json) about dbt releases.
  
  We need to confirm that pre-releases are not shown as the latest version for a package on PyPi.
  
  ### Who will this benefit?
  dbt maintainers :) 
  
  </issue>
  <code>
  [start of dbt/version.py]
  1 import re
  2 
  3 import dbt.semver
  4 
  5 try:
  6     # For Python 3.0 and later
  7     from urllib.request import urlopen
  8 except ImportError:
  9     # Fall back to Python 2's urllib2
  10     from urllib2 import urlopen
  11 
  12 REMOTE_VERSION_FILE = \
  13     'https://raw.githubusercontent.com/fishtown-analytics/dbt/' \
  14     'master/.bumpversion.cfg'
  15 
  16 
  17 def get_version_string_from_text(contents):
  18     matches = re.search(r"current_version = ([\.0-9a-z]+)", contents)
  19     if matches is None or len(matches.groups()) != 1:
  20         return ""
  21     version = matches.groups()[0]
  22     return version
  23 
  24 
  25 def get_remote_version_file_contents(url=REMOTE_VERSION_FILE):
  26     try:
  27         f = urlopen(url)
  28         contents = f.read()
  29     except Exception:
  30         contents = ''
  31     if hasattr(contents, 'decode'):
  32         contents = contents.decode('utf-8')
  33     return contents
  34 
  35 
  36 def get_latest_version():
  37     contents = get_remote_version_file_contents()
  38     if contents == '':
  39         return None
  40     version_string = get_version_string_from_text(contents)
  41     return dbt.semver.VersionSpecifier.from_version_string(version_string)
  42 
  43 
  44 def get_installed_version():
  45     return dbt.semver.VersionSpecifier.from_version_string(__version__)
  46 
  47 
  48 def get_version_information():
  49     installed = get_installed_version()
  50     latest = get_latest_version()
  51 
  52     installed_s = installed.to_version_string(skip_matcher=True)
  53     if latest is None:
  54         latest_s = 'unknown'
  55     else:
  56         latest_s = latest.to_version_string(skip_matcher=True)
  57 
  58     version_msg = ("installed version: {}\n"
  59                    "   latest version: {}\n\n".format(installed_s, latest_s))
  60 
  61     if latest is None:
  62         return ("{}The latest version of dbt could not be determined!\n"
  63                 "Make sure that the following URL is accessible:\n{}"
  64                 .format(version_msg, REMOTE_VERSION_FILE))
  65 
  66     if installed == latest:
  67         return "{}Up to date!".format(version_msg)
  68 
  69     elif installed > latest:
  70         return ("{}Your version of dbt is ahead of the latest "
  71                 "release!".format(version_msg))
  72 
  73     else:
  74         return ("{}Your version of dbt is out of date! "
  75                 "You can find instructions for upgrading here:\n"
  76                 "https://docs.getdbt.com/docs/installation"
  77                 .format(version_msg))
  78 
  79 
  80 __version__ = '0.12.1'
  81 installed = get_installed_version()
  82
  [end of dbt/version.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/dbt/version.py b/dbt/version.py
  --- a/dbt/version.py
  +++ b/dbt/version.py
  @@ -1,43 +1,23 @@
  +import json
   import re
   
  -import dbt.semver
  -
  -try:
  -    # For Python 3.0 and later
  -    from urllib.request import urlopen
  -except ImportError:
  -    # Fall back to Python 2's urllib2
  -    from urllib2 import urlopen
  -
  -REMOTE_VERSION_FILE = \
  -    'https://raw.githubusercontent.com/fishtown-analytics/dbt/' \
  -    'master/.bumpversion.cfg'
  -
  +import requests
   
  -def get_version_string_from_text(contents):
  -    matches = re.search(r"current_version = ([\.0-9a-z]+)", contents)
  -    if matches is None or len(matches.groups()) != 1:
  -        return ""
  -    version = matches.groups()[0]
  -    return version
  +import dbt.exceptions
  +import dbt.semver
   
   
  -def get_remote_version_file_contents(url=REMOTE_VERSION_FILE):
  -    try:
  -        f = urlopen(url)
  -        contents = f.read()
  -    except Exception:
  -        contents = ''
  -    if hasattr(contents, 'decode'):
  -        contents = contents.decode('utf-8')
  -    return contents
  +PYPI_VERSION_URL = 'https://pypi.org/pypi/dbt/json'
   
   
   def get_latest_version():
  -    contents = get_remote_version_file_contents()
  -    if contents == '':
  +    try:
  +        resp = requests.get(PYPI_VERSION_URL)
  +        data = resp.json()
  +        version_string = data['info']['version']
  +    except (json.JSONDecodeError, KeyError, requests.RequestException):
           return None
  -    version_string = get_version_string_from_text(contents)
  +
       return dbt.semver.VersionSpecifier.from_version_string(version_string)
   
   
  @@ -61,7 +41,7 @@
       if latest is None:
           return ("{}The latest version of dbt could not be determined!\n"
                   "Make sure that the following URL is accessible:\n{}"
  -                .format(version_msg, REMOTE_VERSION_FILE))
  +                .format(version_msg, PYPI_VERSION_URL))
   
       if installed == latest:
           return "{}Up to date!".format(version_msg)
  
verification_info: {"golden_diff": "diff --git a/dbt/version.py b/dbt/version.py\n--- a/dbt/version.py\n+++ b/dbt/version.py\n@@ -1,43 +1,23 @@\n+import json\n import re\n \n-import dbt.semver\n-\n-try:\n-    # For Python 3.0 and later\n-    from urllib.request import urlopen\n-except ImportError:\n-    # Fall back to Python 2's urllib2\n-    from urllib2 import urlopen\n-\n-REMOTE_VERSION_FILE = \\\n-    'https://raw.githubusercontent.com/fishtown-analytics/dbt/' \\\n-    'master/.bumpversion.cfg'\n-\n+import requests\n \n-def get_version_string_from_text(contents):\n-    matches = re.search(r\"current_version = ([\\.0-9a-z]+)\", contents)\n-    if matches is None or len(matches.groups()) != 1:\n-        return \"\"\n-    version = matches.groups()[0]\n-    return version\n+import dbt.exceptions\n+import dbt.semver\n \n \n-def get_remote_version_file_contents(url=REMOTE_VERSION_FILE):\n-    try:\n-        f = urlopen(url)\n-        contents = f.read()\n-    except Exception:\n-        contents = ''\n-    if hasattr(contents, 'decode'):\n-        contents = contents.decode('utf-8')\n-    return contents\n+PYPI_VERSION_URL = 'https://pypi.org/pypi/dbt/json'\n \n \n def get_latest_version():\n-    contents = get_remote_version_file_contents()\n-    if contents == '':\n+    try:\n+        resp = requests.get(PYPI_VERSION_URL)\n+        data = resp.json()\n+        version_string = data['info']['version']\n+    except (json.JSONDecodeError, KeyError, requests.RequestException):\n         return None\n-    version_string = get_version_string_from_text(contents)\n+\n     return dbt.semver.VersionSpecifier.from_version_string(version_string)\n \n \n@@ -61,7 +41,7 @@\n     if latest is None:\n         return (\"{}The latest version of dbt could not be determined!\\n\"\n                 \"Make sure that the following URL is accessible:\\n{}\"\n-                .format(version_msg, REMOTE_VERSION_FILE))\n+                .format(version_msg, PYPI_VERSION_URL))\n \n     if installed == latest:\n         return \"{}Up to date!\".format(version_msg)\n", "issue": "don't rely on master branch for latest version number\n## Feature\r\n\r\n### Feature description\r\nThe `master` branch of dbt isn't really a thing anymore. Instead of relying on the [master](https://github.com/fishtown-analytics/dbt/blob/51f68e3aabcda57afbe5051983d1d17e092be665/dbt/version.py#L12) branch to grab the latest release number, we should pull it from PyPi.\r\n\r\nWe can use [this api](https://warehouse.readthedocs.io/api-reference/json/) to fetch [some JSON info](https://pypi.org/pypi/dbt/json) about dbt releases.\r\n\r\nWe need to confirm that pre-releases are not shown as the latest version for a package on PyPi.\r\n\r\n### Who will this benefit?\r\ndbt maintainers :) \n", "before_files": [{"content": "import re\n\nimport dbt.semver\n\ntry:\n    # For Python 3.0 and later\n    from urllib.request import urlopen\nexcept ImportError:\n    # Fall back to Python 2's urllib2\n    from urllib2 import urlopen\n\nREMOTE_VERSION_FILE = \\\n    'https://raw.githubusercontent.com/fishtown-analytics/dbt/' \\\n    'master/.bumpversion.cfg'\n\n\ndef get_version_string_from_text(contents):\n    matches = re.search(r\"current_version = ([\\.0-9a-z]+)\", contents)\n    if matches is None or len(matches.groups()) != 1:\n        return \"\"\n    version = matches.groups()[0]\n    return version\n\n\ndef get_remote_version_file_contents(url=REMOTE_VERSION_FILE):\n    try:\n        f = urlopen(url)\n        contents = f.read()\n    except Exception:\n        contents = ''\n    if hasattr(contents, 'decode'):\n        contents = contents.decode('utf-8')\n    return contents\n\n\ndef get_latest_version():\n    contents = get_remote_version_file_contents()\n    if contents == '':\n        return None\n    version_string = get_version_string_from_text(contents)\n    return dbt.semver.VersionSpecifier.from_version_string(version_string)\n\n\ndef get_installed_version():\n    return dbt.semver.VersionSpecifier.from_version_string(__version__)\n\n\ndef get_version_information():\n    installed = get_installed_version()\n    latest = get_latest_version()\n\n    installed_s = installed.to_version_string(skip_matcher=True)\n    if latest is None:\n        latest_s = 'unknown'\n    else:\n        latest_s = latest.to_version_string(skip_matcher=True)\n\n    version_msg = (\"installed version: {}\\n\"\n                   \"   latest version: {}\\n\\n\".format(installed_s, latest_s))\n\n    if latest is None:\n        return (\"{}The latest version of dbt could not be determined!\\n\"\n                \"Make sure that the following URL is accessible:\\n{}\"\n                .format(version_msg, REMOTE_VERSION_FILE))\n\n    if installed == latest:\n        return \"{}Up to date!\".format(version_msg)\n\n    elif installed > latest:\n        return (\"{}Your version of dbt is ahead of the latest \"\n                \"release!\".format(version_msg))\n\n    else:\n        return (\"{}Your version of dbt is out of date! \"\n                \"You can find instructions for upgrading here:\\n\"\n                \"https://docs.getdbt.com/docs/installation\"\n                .format(version_msg))\n\n\n__version__ = '0.12.1'\ninstalled = get_installed_version()\n", "path": "dbt/version.py"}]}