Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 4 additions & 36 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ jobs:
- "3.12"
- "3.13"
- "3.14"
- "pypy-2.7"
- "pypy-3.7"
- "pypy-3.8"
- "pypy-3.9"
Expand All @@ -50,12 +49,6 @@ jobs:
- os: ubuntu-latest
container: python:3.6
python-version: "3.6"
- os: ubuntu-latest
container: python:3.5
python-version: "3.5"
- os: ubuntu-latest
container: python:2.7-buster
python-version: "2.7"
exclude:
- os: macos-latest
python-version: "pypy-3.7"
Expand All @@ -66,18 +59,6 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Ignore certificate verification on python 3.5
shell: bash
run: |
# INSECURE!! But it should be OK for CI tests.
echo 'PIP_TRUSTED_HOST=pypi.python.org pypi.org files.pythonhosted.org' >>$GITHUB_ENV
if: 'matrix.python-version == 3.5'

- name: set PIP_NO_PYTHON_VERSION_WARNING environment variable for python 2
shell: bash
run: echo 'PIP_NO_PYTHON_VERSION_WARNING=1' >>$GITHUB_ENV
if: ${{ matrix.python-version == '2.7' || matrix.python-version == 'pypy-2.7' }}

- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
Expand All @@ -101,22 +82,13 @@ jobs:
echo IS_PYPY=$IS_PYPY >>$GITHUB_ENV
echo TOX_PYTHON=$V >>$GITHUB_ENV

if [[ ${{ matrix.python-version }} = *2.7 ]]; then
python -m pip install tox
else
python -Im pip install tox
fi
python -Im pip install tox

- name: Prepare sdist and source-dir
shell: bash
run: |
if [[ ${{ matrix.python-version }} = *2.7 ]]; then
python -m pip install build
python -m build
else
python -Im pip install build
python -Im build
fi
python -Im pip install build
python -Im build

mkdir source-dir
tar -xzvf dist/wcwidth-*.tar.gz -C source-dir --strip-components=1
Expand All @@ -125,11 +97,7 @@ jobs:
shell: bash
working-directory: ./source-dir
run: |
if [[ ${{ matrix.python-version }} = *2.7 ]]; then
python -m tox -e ${{ env.TOX_PYTHON }}
else
python -Im tox -e ${{ env.TOX_PYTHON }}
fi
python -Im tox -e ${{ env.TOX_PYTHON }}

- name: Rename coverage data
shell: bash
Expand Down
23 changes: 9 additions & 14 deletions bin/wcwidth-browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
# Invalid constant name "echo"
# Invalid constant name "flushout" (col 4)
# Invalid module name "wcwidth-browser"
from __future__ import division, print_function

# std imports
import sys
Expand All @@ -44,7 +43,7 @@

#: printable length of highest unicode character description
LIMIT_UCS = 0x3fffd
UCS_PRINTLEN = len('{value:0x}'.format(value=LIMIT_UCS))
UCS_PRINTLEN = len(f'{LIMIT_UCS:0x}')


def readline(term, width):
Expand All @@ -69,7 +68,7 @@ def readline(term, width):
return text


class WcWideCharacterGenerator(object):
class WcWideCharacterGenerator:
"""Generator yields unicode characters of the given ``width``."""

# pylint: disable=R0903
Expand Down Expand Up @@ -101,7 +100,7 @@ def __next__(self):
return (ucs, name)


class WcCombinedCharacterGenerator(object):
class WcCombinedCharacterGenerator:
"""Generator yields unicode characters with combining."""

# pylint: disable=R0903
Expand Down Expand Up @@ -148,11 +147,8 @@ def __next__(self):
continue
return (ucs, name)

# python 2.6 - 3.3 compatibility
next = __next__


class Style(object):
class Style:
"""Styling decorator class instance for terminal output."""

# pylint: disable=R0903
Expand Down Expand Up @@ -184,7 +180,7 @@ def __init__(self, **kwargs):
setattr(self, key, val)


class Screen(object):
class Screen:
"""Represents terminal style, data dimensions, and drawables."""

intro_msg_fmt = ('Delimiters ({delim}) should align, '
Expand Down Expand Up @@ -217,8 +213,7 @@ def head_item(self):
"""Text of a single column heading."""
delimiter = self.style.attr_minor(self.style.delimiter)
hint = self.style.header_hint * self.wide
heading = ('{delimiter}{hint}{delimiter}'
.format(delimiter=delimiter, hint=hint))
heading = f'{delimiter}{hint}{delimiter}'

def alignment(*args):
if self.style.alignment == 'right':
Expand Down Expand Up @@ -264,7 +259,7 @@ def page_size(self):
return self.num_rows * self.num_columns


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

Expand Down Expand Up @@ -570,10 +565,10 @@ def draw_status(self, writer, idx):
if idx == self.last_page:
last_end = '(END)'
else:
last_end = '/{0}'.format(self.last_page)
last_end = f'/{self.last_page}'
txt = ('Page {idx}{last_end} - '
'{q} to quit, [keys: {keyset}]'
.format(idx=style.attr_minor('{0}'.format(idx)),
.format(idx=style.attr_minor(f'{idx}'),
last_end=style.attr_major(last_end),
keyset=style.attr_major('kjfbvc12-='),
q=style.attr_minor('q')))
Expand Down
21 changes: 3 additions & 18 deletions bin/wcwidth-libc-comparator.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env python
# coding: utf-8
"""
Manual tests comparing wcwidth.py to libc's wcwidth(3) and wcswidth(3).

Expand All @@ -18,7 +17,6 @@
# Invalid module name "wcwidth-libc-comparator"

# standard imports
from __future__ import print_function

# std imports
import sys
Expand Down Expand Up @@ -64,25 +62,12 @@ def report_ucs_msg(ucs, wcwidth_libc, wcwidth_local):
.decode('ascii')
.upper()
.lstrip('0'))
url = "http://codepoints.net/U+{}".format(ucp)
url = f"http://codepoints.net/U+{ucp}"
name = unicodedata.name(ucs)
return (u"libc,ours={},{} [--o{}o--] name={} val={} {}"
return ("libc,ours={},{} [--o{}o--] name={} val={} {}"
" ".format(wcwidth_libc, wcwidth_local, ucs, name, ord(ucs), url))


# use chr() for py3.x,
# unichr() for py2.x
try:
_ = unichr(0)
except NameError as err:
if err.args[0] == "name 'unichr' is not defined":
# pylint: disable=W0622
# Redefining built-in 'unichr' (col 8)

unichr = chr
else:
raise

if sys.maxunicode < 1114111:
warnings.warn('narrow Python build, only a small subset of '
'characters may be tested.')
Expand All @@ -108,7 +93,7 @@ def main(using_locale=('en_US', 'UTF-8',)):
report a detailed AssertionError to stdout.
"""
all_ucs = (ucs for ucs in
[unichr(val) for val in range(sys.maxunicode)]
[chr(val) for val in range(sys.maxunicode)]
if is_named(ucs) and is_not_combining(ucs))

libc_name = ctypes.util.find_library('c')
Expand Down
1 change: 0 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# wcwidth documentation build configuration file, created by
# sphinx-quickstart on Fri Oct 20 15:18:02 2017.
Expand Down
2 changes: 1 addition & 1 deletion docs/intro.rst
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ Install wcwidth in editable mode::

Execute unit tests using tox_::

tox -e py27,py35,py36,py37,py38,py39,py310,py311,py312,py313,py314
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

py313 and py314 were accidentally removed.

tox -e py36,py37,py38,py39,py310,py311,py312

Updating Unicode Version
------------------------
Expand Down
2 changes: 0 additions & 2 deletions setup.cfg

This file was deleted.

5 changes: 1 addition & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,24 +51,21 @@ def main():
_get_here('README.rst'), 'rb', 'utf8').read(),
author='Jeff Quast',
author_email='[email protected]',
install_requires=('backports.functools-lru-cache>=1.2.1;'
'python_version < "3.2"'),
license='MIT',
packages=['wcwidth'],
url='https://github.com/jquast/wcwidth',
package_data={
'': ['LICENSE', '*.rst'],
},
zip_safe=True,
python_requires='>=3.6',
classifiers=[
'Intended Audience :: Developers',
'Natural Language :: English',
'Development Status :: 5 - Production/Stable',
'Environment :: Console',
'License :: OSI Approved :: MIT License',
'Operating System :: POSIX',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
Expand Down
Loading
Loading