Skip to content

Commit

Permalink
Merge pull request #177 from MatthijsBurgh/master
Browse files Browse the repository at this point in the history
Drop py2 support; Extend py3 support; Fix CI; enable dependabot
  • Loading branch information
gruns authored Nov 6, 2024
2 parents 0f6c1ae + 35ed732 commit 0947616
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 49 deletions.
6 changes: 6 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
27 changes: 15 additions & 12 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,32 @@ jobs:
build:
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
include:
- python-version: 2.7
toxenv: py27
- python-version: 3.5
- python-version: '3.5'
toxenv: py35
- python-version: 3.6
- python-version: '3.6'
toxenv: py36
- python-version: 3.7
- python-version: '3.7'
toxenv: py37
- python-version: 3.8
- python-version: '3.8'
toxenv: py38
- python-version: 3.9
- python-version: '3.9'
toxenv: py39
- python-version: pypy-2.7
toxenv: pypy
- python-version: pypy-3.7
- python-version: '3.10'
toxenv: py310
- python-version: '3.11'
toxenv: py311
- python-version: '3.12'
toxenv: py312
- python-version: 'pypy-3.10'
toxenv: pypy3

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install tox
Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ do. IceCream, or `ic` for short, makes print debugging a little sweeter.
5. It optionally includes program context: filename, line number, and
parent function.

IceCream is well tested, [permissively licensed](LICENSE.txt), and
supports Python 2, Python 3, PyPy2, and PyPy3.
IceCream is well tested, [permissively licensed](LICENSE.txt), and supports Python 3 and PyPy3.


### Inspect Variables
Expand Down
12 changes: 1 addition & 11 deletions icecream/icecream.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@
from .coloring import SolarizedDark


PYTHON2 = (sys.version_info[0] == 2)

_absent = object()


Expand All @@ -50,7 +48,7 @@ def decorator(fn):

@bindStaticVariable('formatter', Terminal256Formatter(style=SolarizedDark))
@bindStaticVariable(
'lexer', PyLexer(ensurenl=False) if PYTHON2 else Py3Lexer(ensurenl=False))
'lexer', Py3Lexer(ensurenl=False))
def colorize(s):
self = colorize
return highlight(s, self.lexer, self.formatter)
Expand Down Expand Up @@ -160,14 +158,6 @@ def formatPair(prefix, arg, value):


def singledispatch(func):
if "singledispatch" not in dir(functools):
def unsupport_py2(*args, **kwargs):
raise NotImplementedError(
"functools.singledispatch is missing in " + sys.version
)
func.register = func.unregister = unsupport_py2
return func

func = functools.singledispatch(func)

# add unregister based on https://stackoverflow.com/a/25951784
Expand Down
9 changes: 5 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def run(self):
os.system('python setup.py sdist bdist_wheel')

sdist = 'dist/icecream-%s.tar.gz' % meta['__version__']
wheel = 'dist/icecream-%s-py2.py3-none-any.whl' % meta['__version__']
wheel = 'dist/icecream-%s-py3-none-any.whl' % meta['__version__']
rc = os.system('twine upload "%s" "%s"' % (sdist, wheel))

sys.exit(rc)
Expand Down Expand Up @@ -86,8 +86,6 @@ def run_tests(self):
'Topic :: Software Development :: Libraries',
'Development Status :: 4 - Beta',
'Programming Language :: Python',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
Expand All @@ -96,10 +94,13 @@ def run_tests(self):
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: 3.12',
'Programming Language :: Python :: Implementation :: PyPy',
'Programming Language :: Python :: Implementation :: CPython',
],
tests_require=[],
tests_require=[
'tox>=4',
],
install_requires=[
'colorama>=0.3.9',
'pygments>=2.2.0',
Expand Down
Empty file added tests/__init__.py
Empty file.
16 changes: 2 additions & 14 deletions tests/test_icecream.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@
import unittest
import warnings

try: # Python 2.x.
from StringIO import StringIO
except ImportError: # Python 3.x.
from io import StringIO
from io import StringIO
from contextlib import contextmanager
from os.path import basename, splitext, realpath

Expand Down Expand Up @@ -396,15 +393,6 @@ def testSingledispatchArgumentToString(self):
def argumentToString_tuple(obj):
return "Dispatching tuple!"

# Unsupport Python2
if "singledispatch" not in dir(functools):
for attr in ("register", "unregister"):
with self.assertRaises(NotImplementedError):
getattr(argumentToString, attr)(
tuple, argumentToString_tuple
)
return

# Prepare input and output
x = (1, 2)
default_output = ic.format(x)
Expand Down Expand Up @@ -600,7 +588,7 @@ def testMultilineContainerArgs(self):
list(range(15))])

lines = err.getvalue().strip().splitlines()
self.assertRegexpMatches(
self.assertRegex(
lines[0],
r'ic\| test_icecream.py:\d+ in testMultilineContainerArgs\(\)',
)
Expand Down
4 changes: 2 additions & 2 deletions tests/test_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
import unittest

import icecream
from test_icecream import (
from .test_icecream import (
disableColoring, captureStandardStreams, parseOutputIntoPairs)

from install_test_import import runMe
from .install_test_import import runMe


class TestIceCreamInstall(unittest.TestCase):
Expand Down
7 changes: 3 additions & 4 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
[tox]
envlist = py27, py35, py36, py37, py38, py39, pypy, pypy3
envlist = py35, py36, py37, py38, py39, py310, py311, py312, pypy3

[testenv]
deps =
nose
description = run unittest
commands =
nosetests --exe []
python -m unittest

0 comments on commit 0947616

Please sign in to comment.