Skip to content

Commit

Permalink
Drop support for Python 2.7
Browse files Browse the repository at this point in the history
It's dead, Jim.

Signed-off-by: Stephen Finucane <[email protected]>
  • Loading branch information
stephenfin committed Jul 8, 2020
1 parent 2a1a229 commit 613df41
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 15 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ language: python
sudo: false
cache: pip
python:
- 2.7
- 3.5
- 3.6
- 3.7
Expand Down
14 changes: 9 additions & 5 deletions git_pw/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,24 @@
from __future__ import print_function

import csv
import io
import os
import subprocess
import sys

import click
import six
from tabulate import tabulate


def ensure_str(s):
if s is None:
s = ''
elif not isinstance(s, (six.text_type, six.binary_type)):
elif isinstance(s, bytes):
s = s.decode('utf-8', 'strict')
elif not isinstance(s, str):
s = str(s)

return six.ensure_str(s)
return s


def trim(string, length=70): # type: (str, int) -> str
Expand Down Expand Up @@ -68,7 +70,7 @@ def _tabulate(output, headers, fmt):
elif fmt == 'simple':
return tabulate(output, headers, tablefmt='simple')
elif fmt == 'csv':
result = six.StringIO()
result = io.StringIO()
writer = csv.writer(
result, quoting=csv.QUOTE_ALL, lineterminator=os.linesep)
writer.writerow([ensure_str(h) for h in headers])
Expand All @@ -89,7 +91,9 @@ def _echo_via_pager(pager, output):

pager = subprocess.Popen(pager.split(), stdin=subprocess.PIPE, env=env)

output = six.ensure_binary(output)
# TODO(stephenfin): This is potential hangover from Python 2 days
if not isinstance(output, bytes):
output = output.encode('utf-8', 'strict')

try:
pager.communicate(input=output)
Expand Down
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@ click>=6.0,<8.0
requests>2.0,<3.0
tabulate>=0.8
arrow>=0.10
six>=1.12
7 changes: 2 additions & 5 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ description-file = README.rst
license = MIT License
license_file = LICENSE
classifiers =
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
Programming Language :: Python
Development Status :: 4 - Beta
Environment :: Console
Expand All @@ -25,7 +25,7 @@ project_urls =
Bug Tracker = https://github.com/getpatchwork/git-pw/issues
Source Code = https://github.com/getpatchwork/git-pw
Documentation = https://git-pw.readthedocs.io
python_requires = >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*
python_requires = >=3.5

[files]
packages =
Expand All @@ -34,6 +34,3 @@ packages =
[entry_points]
console_scripts =
git-pw = git_pw.shell:cli

[bist_wheel]
universal = 1
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3

from setuptools import setup

Expand Down
3 changes: 1 addition & 2 deletions test-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
mock~=3.0.0
pytest>=3.0,<6.0;python_version>='3.5'
pytest>=3.0,<5.0;python_version=='2.7'
pytest>=3.0,<6.0
pytest-cov~=2.5

0 comments on commit 613df41

Please sign in to comment.