From ed0e4379c967cc53db2911345e86ce7744b24032 Mon Sep 17 00:00:00 2001 From: Joe Gordon Date: Thu, 16 Jul 2020 09:54:21 -0700 Subject: [PATCH 1/2] Drop Python 2.7 support and add 3.8 support * cgi.escape was removed in 3.8 https://docs.python.org/3/whatsnew/3.8.html#api-and-feature-removals Use html.escape instead as recommended * Drop usage of six * Update testing to add Python 3.8 and drop Python 2.7, Python 3.5 * and remove travis code --- .github/workflows/ci.yml | 4 ++-- .travis.yml | 14 -------------- git_stacktrace/git.py | 11 +++-------- git_stacktrace/parse_trace.py | 7 ++----- git_stacktrace/server.py | 6 +++--- requirements.txt | 1 - setup.cfg | 5 ++--- tox.ini | 9 +-------- 8 files changed, 13 insertions(+), 44 deletions(-) delete mode 100644 .travis.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b525c01..8103606 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,7 +13,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: [2.7, 3.5, 3.6, 3.7, pypy2, pypy3] + python-version: [3.6, 3.7, 3.8, pypy3] steps: - uses: actions/checkout@v2 @@ -24,7 +24,7 @@ jobs: - name: Install Tox and any other packages run: pip install tox - name: Lint - if: matrix.python-version == '2.7' || matrix.python-version == '3.7' + if: matrix.python-version == '3.8' run: | pip install flake8 flake8 git_stacktrace diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index b7bddd4..0000000 --- a/.travis.yml +++ /dev/null @@ -1,14 +0,0 @@ -sudo: false -language: python -python: - - "2.7" - - "3.5" - - "3.6" -matrix: - include: - - python: 3.7 - dist: xenial - sudo: true -cache: pip -install: pip install tox-travis -script: tox diff --git a/git_stacktrace/git.py b/git_stacktrace/git.py index c996fd6..f931d5b 100644 --- a/git_stacktrace/git.py +++ b/git_stacktrace/git.py @@ -8,7 +8,6 @@ import shlex import os -import six import whatthepatch SHA1_REGEX = re.compile(r'\b[0-9a-f]{40}\b') @@ -38,7 +37,7 @@ def __repr__(self): return self.filename def __eq__(self, other): - if isinstance(other, six.string_types): + if isinstance(other, str): other_filename = other else: other_filename = other.filename @@ -47,11 +46,7 @@ def __eq__(self, other): def run_command_status(*argv, **kwargs): if len(argv) == 1: - # for python2 compatibility with shlex - if sys.version_info < (3,) and isinstance(argv[0], six.text_type): - argv = shlex.split(argv[0].encode('utf-8')) - else: - argv = shlex.split(str(argv[0])) + argv = shlex.split(str(argv[0])) stdin = kwargs.pop('stdin', None) newenv = os.environ.copy() newenv['LANG'] = 'C' @@ -105,7 +100,7 @@ def pickaxe(snippet, git_range, filename=None): Return list of commits that modified that snippet """ - cmd = 'git', 'log', '-b', '--pretty=%H', '-S', six.u(snippet), git_range + cmd = 'git', 'log', '-b', '--pretty=%H', '-S', str(snippet), git_range if filename: cmd = cmd + ('--', filename,) commits = run_command(*cmd).splitlines() diff --git a/git_stacktrace/parse_trace.py b/git_stacktrace/parse_trace.py index 0068d70..454d814 100644 --- a/git_stacktrace/parse_trace.py +++ b/git_stacktrace/parse_trace.py @@ -9,8 +9,6 @@ import re import traceback -import six - log = logging.getLogger(__name__) @@ -35,8 +33,7 @@ def traceback_format(self): return (self.trace_filename, self.line_number, self.function_name, self.code) -@six.add_metaclass(abc.ABCMeta) -class Traceback(object): +class Traceback(object, metaclass=abc.ABCMeta): def __init__(self, blob): self.header = "" @@ -52,7 +49,7 @@ def prep_blob(self, blob): if len(blob) == 1: blob = blob[0].replace('\\n', '\n').split('\n') # Split by line - if type(blob) == str or type(blob) == six.text_type: + if isinstance(blob, str): lines = blob.split('\n') elif type(blob) == list: if len(blob) == 1: diff --git a/git_stacktrace/server.py b/git_stacktrace/server.py index da708a3..9c1aee7 100644 --- a/git_stacktrace/server.py +++ b/git_stacktrace/server.py @@ -4,10 +4,10 @@ import logging import os -from cgi import escape +from html import escape from git_stacktrace import api -from six.moves.html_parser import HTMLParser -from six.moves.urllib_parse import parse_qs +from html.parser import HTMLParser +from urllib.parse import parse_qs from string import Template from datetime import date, datetime diff --git a/requirements.txt b/requirements.txt index ebc026e..30630f2 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1 @@ whatthepatch -six diff --git a/setup.cfg b/setup.cfg index 0a3dd03..4c7ae08 100644 --- a/setup.cfg +++ b/setup.cfg @@ -3,11 +3,10 @@ name = git-stacktrace author = Joe Gordon license = Apache License (2.0) classifier = - Programming Language :: Python :: 2 - Programming Language :: Python :: 2.7 Programming Language :: Python :: 3 - Programming Language :: Python :: 3.5 Programming Language :: Python :: 3.6 + Programming Language :: Python :: 3.7 + Programming Language :: Python :: 3.8 Intended Audience :: Developers Operating System :: OS Independent License :: OSI Approved :: Apache Software License diff --git a/tox.ini b/tox.ini index 4ed18dc..cd60700 100644 --- a/tox.ini +++ b/tox.ini @@ -1,15 +1,8 @@ [tox] minversion = 2.0 -envlist=py27,py37,flake8,docs +envlist=py37,py38,flake8,docs skipsdist=False -[travis] -python = - 2.7: py27, flake8, docs - 3.5: py35, flake8, docs - 3.6: py36, flake8, docs - 3.7: py37, flake8, docs - [testenv] usedevelop = True install_command = pip install -U {opts} {packages} From a272c4c41ef6ec6adcc7d334ef8dfd9f90f0097c Mon Sep 17 00:00:00 2001 From: Joe Gordon Date: Thu, 16 Jul 2020 10:03:19 -0700 Subject: [PATCH 2/2] Update CHANGES with PR --- CHANGES.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGES.rst b/CHANGES.rst index 01be7ea..b70aed8 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,6 +1,11 @@ Change Log ========== +1.0.0 +----- + +* Add Python 3.8 support drop Python 2.7 support (https://github.com/pinterest/git-stacktrace/pull/33) + 0.9.0 -----