Skip to content

Commit 56b4327

Browse files
authored
Merge pull request #117 from hugovk/master
Drop support for EOL Python 2.7 and 3.5
2 parents 358a676 + a753ba4 commit 56b4327

File tree

12 files changed

+114
-218
lines changed

12 files changed

+114
-218
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ jobs:
3434
- "3.12"
3535
- "3.13"
3636
- "3.14"
37-
- "pypy-2.7"
3837
- "pypy-3.7"
3938
- "pypy-3.8"
4039
- "pypy-3.9"
@@ -50,12 +49,6 @@ jobs:
5049
- os: ubuntu-latest
5150
container: python:3.6
5251
python-version: "3.6"
53-
- os: ubuntu-latest
54-
container: python:3.5
55-
python-version: "3.5"
56-
- os: ubuntu-latest
57-
container: python:2.7-buster
58-
python-version: "2.7"
5952
exclude:
6053
- os: macos-latest
6154
python-version: "pypy-3.7"
@@ -66,18 +59,6 @@ jobs:
6659
steps:
6760
- uses: actions/checkout@v4
6861

69-
- name: Ignore certificate verification on python 3.5
70-
shell: bash
71-
run: |
72-
# INSECURE!! But it should be OK for CI tests.
73-
echo 'PIP_TRUSTED_HOST=pypi.python.org pypi.org files.pythonhosted.org' >>$GITHUB_ENV
74-
if: 'matrix.python-version == 3.5'
75-
76-
- name: set PIP_NO_PYTHON_VERSION_WARNING environment variable for python 2
77-
shell: bash
78-
run: echo 'PIP_NO_PYTHON_VERSION_WARNING=1' >>$GITHUB_ENV
79-
if: ${{ matrix.python-version == '2.7' || matrix.python-version == 'pypy-2.7' }}
80-
8162
- uses: actions/setup-python@v5
8263
with:
8364
python-version: ${{ matrix.python-version }}
@@ -101,22 +82,13 @@ jobs:
10182
echo IS_PYPY=$IS_PYPY >>$GITHUB_ENV
10283
echo TOX_PYTHON=$V >>$GITHUB_ENV
10384
104-
if [[ ${{ matrix.python-version }} = *2.7 ]]; then
105-
python -m pip install tox
106-
else
107-
python -Im pip install tox
108-
fi
85+
python -Im pip install tox
10986
11087
- name: Prepare sdist and source-dir
11188
shell: bash
11289
run: |
113-
if [[ ${{ matrix.python-version }} = *2.7 ]]; then
114-
python -m pip install build
115-
python -m build
116-
else
117-
python -Im pip install build
118-
python -Im build
119-
fi
90+
python -Im pip install build
91+
python -Im build
12092
12193
mkdir source-dir
12294
tar -xzvf dist/wcwidth-*.tar.gz -C source-dir --strip-components=1
@@ -125,11 +97,7 @@ jobs:
12597
shell: bash
12698
working-directory: ./source-dir
12799
run: |
128-
if [[ ${{ matrix.python-version }} = *2.7 ]]; then
129-
python -m tox -e ${{ env.TOX_PYTHON }}
130-
else
131-
python -Im tox -e ${{ env.TOX_PYTHON }}
132-
fi
100+
python -Im tox -e ${{ env.TOX_PYTHON }}
133101
134102
- name: Rename coverage data
135103
shell: bash

bin/wcwidth-browser.py

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
# Invalid constant name "echo"
2323
# Invalid constant name "flushout" (col 4)
2424
# Invalid module name "wcwidth-browser"
25-
from __future__ import division, print_function
2625

2726
# std imports
2827
import sys
@@ -44,7 +43,7 @@
4443

4544
#: printable length of highest unicode character description
4645
LIMIT_UCS = 0x3fffd
47-
UCS_PRINTLEN = len('{value:0x}'.format(value=LIMIT_UCS))
46+
UCS_PRINTLEN = len(f'{LIMIT_UCS:0x}')
4847

4948

5049
def readline(term, width):
@@ -69,7 +68,7 @@ def readline(term, width):
6968
return text
7069

7170

72-
class WcWideCharacterGenerator(object):
71+
class WcWideCharacterGenerator:
7372
"""Generator yields unicode characters of the given ``width``."""
7473

7574
# pylint: disable=R0903
@@ -101,7 +100,7 @@ def __next__(self):
101100
return (ucs, name)
102101

103102

104-
class WcCombinedCharacterGenerator(object):
103+
class WcCombinedCharacterGenerator:
105104
"""Generator yields unicode characters with combining."""
106105

107106
# pylint: disable=R0903
@@ -148,11 +147,8 @@ def __next__(self):
148147
continue
149148
return (ucs, name)
150149

151-
# python 2.6 - 3.3 compatibility
152-
next = __next__
153150

154-
155-
class Style(object):
151+
class Style:
156152
"""Styling decorator class instance for terminal output."""
157153

158154
# pylint: disable=R0903
@@ -184,7 +180,7 @@ def __init__(self, **kwargs):
184180
setattr(self, key, val)
185181

186182

187-
class Screen(object):
183+
class Screen:
188184
"""Represents terminal style, data dimensions, and drawables."""
189185

190186
intro_msg_fmt = ('Delimiters ({delim}) should align, '
@@ -217,8 +213,7 @@ def head_item(self):
217213
"""Text of a single column heading."""
218214
delimiter = self.style.attr_minor(self.style.delimiter)
219215
hint = self.style.header_hint * self.wide
220-
heading = ('{delimiter}{hint}{delimiter}'
221-
.format(delimiter=delimiter, hint=hint))
216+
heading = f'{delimiter}{hint}{delimiter}'
222217

223218
def alignment(*args):
224219
if self.style.alignment == 'right':
@@ -264,7 +259,7 @@ def page_size(self):
264259
return self.num_rows * self.num_columns
265260

266261

267-
class Pager(object):
262+
class Pager:
268263
"""A less(1)-like browser for browsing unicode characters."""
269264
# pylint: disable=too-many-instance-attributes
270265

@@ -570,10 +565,10 @@ def draw_status(self, writer, idx):
570565
if idx == self.last_page:
571566
last_end = '(END)'
572567
else:
573-
last_end = '/{0}'.format(self.last_page)
568+
last_end = f'/{self.last_page}'
574569
txt = ('Page {idx}{last_end} - '
575570
'{q} to quit, [keys: {keyset}]'
576-
.format(idx=style.attr_minor('{0}'.format(idx)),
571+
.format(idx=style.attr_minor(f'{idx}'),
577572
last_end=style.attr_major(last_end),
578573
keyset=style.attr_major('kjfbvc12-='),
579574
q=style.attr_minor('q')))

bin/wcwidth-libc-comparator.py

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#!/usr/bin/env python
2-
# coding: utf-8
32
"""
43
Manual tests comparing wcwidth.py to libc's wcwidth(3) and wcswidth(3).
54
@@ -18,7 +17,6 @@
1817
# Invalid module name "wcwidth-libc-comparator"
1918

2019
# standard imports
21-
from __future__ import print_function
2220

2321
# std imports
2422
import sys
@@ -64,25 +62,12 @@ def report_ucs_msg(ucs, wcwidth_libc, wcwidth_local):
6462
.decode('ascii')
6563
.upper()
6664
.lstrip('0'))
67-
url = "http://codepoints.net/U+{}".format(ucp)
65+
url = f"http://codepoints.net/U+{ucp}"
6866
name = unicodedata.name(ucs)
69-
return (u"libc,ours={},{} [--o{}o--] name={} val={} {}"
67+
return ("libc,ours={},{} [--o{}o--] name={} val={} {}"
7068
" ".format(wcwidth_libc, wcwidth_local, ucs, name, ord(ucs), url))
7169

7270

73-
# use chr() for py3.x,
74-
# unichr() for py2.x
75-
try:
76-
_ = unichr(0)
77-
except NameError as err:
78-
if err.args[0] == "name 'unichr' is not defined":
79-
# pylint: disable=W0622
80-
# Redefining built-in 'unichr' (col 8)
81-
82-
unichr = chr
83-
else:
84-
raise
85-
8671
if sys.maxunicode < 1114111:
8772
warnings.warn('narrow Python build, only a small subset of '
8873
'characters may be tested.')
@@ -108,7 +93,7 @@ def main(using_locale=('en_US', 'UTF-8',)):
10893
report a detailed AssertionError to stdout.
10994
"""
11095
all_ucs = (ucs for ucs in
111-
[unichr(val) for val in range(sys.maxunicode)]
96+
[chr(val) for val in range(sys.maxunicode)]
11297
if is_named(ucs) and is_not_combining(ucs))
11398

11499
libc_name = ctypes.util.find_library('c')

docs/conf.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#!/usr/bin/env python3
2-
# -*- coding: utf-8 -*-
32
#
43
# wcwidth documentation build configuration file, created by
54
# sphinx-quickstart on Fri Oct 20 15:18:02 2017.

docs/intro.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ Install wcwidth in editable mode::
107107

108108
Execute unit tests using tox_::
109109

110-
tox -e py27,py35,py36,py37,py38,py39,py310,py311,py312,py313,py314
110+
tox -e py36,py37,py38,py39,py310,py311,py312
111111

112112
Updating Unicode Version
113113
------------------------

setup.cfg

Lines changed: 0 additions & 2 deletions
This file was deleted.

setup.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,24 +51,21 @@ def main():
5151
_get_here('README.rst'), 'rb', 'utf8').read(),
5252
author='Jeff Quast',
5353
author_email='contact@jeffquast.com',
54-
install_requires=('backports.functools-lru-cache>=1.2.1;'
55-
'python_version < "3.2"'),
5654
license='MIT',
5755
packages=['wcwidth'],
5856
url='https://github.com/jquast/wcwidth',
5957
package_data={
6058
'': ['LICENSE', '*.rst'],
6159
},
6260
zip_safe=True,
61+
python_requires='>=3.6',
6362
classifiers=[
6463
'Intended Audience :: Developers',
6564
'Natural Language :: English',
6665
'Development Status :: 5 - Production/Stable',
6766
'Environment :: Console',
6867
'License :: OSI Approved :: MIT License',
6968
'Operating System :: POSIX',
70-
'Programming Language :: Python :: 2.7',
71-
'Programming Language :: Python :: 3.5',
7269
'Programming Language :: Python :: 3.6',
7370
'Programming Language :: Python :: 3.7',
7471
'Programming Language :: Python :: 3.8',

0 commit comments

Comments
 (0)