diff options
-rw-r--r-- | .travis.yml | 12 | ||||
-rw-r--r-- | README.md | 42 | ||||
-rw-r--r-- | blinker/_saferef.py | 2 | ||||
-rw-r--r-- | blinker/_utilities.py | 14 | ||||
-rw-r--r-- | blinker/base.py | 4 | ||||
-rw-r--r-- | docs/source/index.rst | 4 | ||||
-rw-r--r-- | setup.py | 9 | ||||
-rw-r--r-- | tests/test_signals.py | 21 | ||||
-rw-r--r-- | tox.ini | 2 |
9 files changed, 38 insertions, 72 deletions
diff --git a/.travis.yml b/.travis.yml index 7af8b0a..cb889b5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,10 +2,6 @@ language: python matrix: include: - - python: 2.6 - os: linux - dist: trusty - env: TOXENV=py26 - python: 2.7 os: linux dist: trusty @@ -14,14 +10,6 @@ matrix: os: linux dist: trusty env: TOXENV=pypy - - python: 3.3 - os: linux - dist: trusty - env: TOXENV=py33 - - python: 3.4 - os: linux - dist: trusty - env: TOXENV=py34 - python: 3.5 os: linux dist: trusty @@ -9,31 +9,33 @@ interested parties to subscribe to events, or "signals". Signal receivers can subscribe to specific senders or receive signals sent by any sender. - >>> from blinker import signal - >>> started = signal('round-started') - >>> def each(round): - ... print "Round %s!" % round - ... - >>> started.connect(each) - - >>> def round_two(round): - ... print "This is round two." - ... - >>> started.connect(round_two, sender=2) - - >>> for round in range(1, 4): - ... started.send(round) - ... - Round 1! - Round 2! - This is round two. - Round 3! +```python +>>> from blinker import signal +>>> started = signal('round-started') +>>> def each(round): +... print "Round %s!" % round +... +>>> started.connect(each) + +>>> def round_two(round): +... print "This is round two." +... +>>> started.connect(round_two, sender=2) + +>>> for round in range(1, 4): +... started.send(round) +... +Round 1! +Round 2! +This is round two. +Round 3! +``` See the [Blinker documentation](https://pythonhosted.org/blinker/) for more information. ## Requirements -Blinker requires Python 2.4 or higher, Python 3.0 or higher, or Jython 2.5 or higher. +Blinker requires Python 2.7, Python 3.4 or higher, or Jython 2.7 or higher. ## Changelog Summary diff --git a/blinker/_saferef.py b/blinker/_saferef.py index 269e362..081173d 100644 --- a/blinker/_saferef.py +++ b/blinker/_saferef.py @@ -198,7 +198,7 @@ class BoundMethodWeakref(object): def __str__(self): """Give a friendly representation of the object.""" - return "%s(%s.%s)" % ( + return "{}({}.{})".format( self.__class__.__name__, self.self_name, self.func_name, diff --git a/blinker/_utilities.py b/blinker/_utilities.py index 056270d..133c57a 100644 --- a/blinker/_utilities.py +++ b/blinker/_utilities.py @@ -36,7 +36,7 @@ except: def __reduce__(self): if self.default_factory is None: - args = tuple() + args = () else: args = self.default_factory, return type(self), args, None, None, self.items() @@ -53,20 +53,10 @@ except: copy.deepcopy(self.items())) def __repr__(self): - return 'defaultdict(%s, %s)' % (self.default_factory, + return 'defaultdict({}, {})'.format(self.default_factory, dict.__repr__(self)) -try: - from contextlib import contextmanager -except ImportError: - def contextmanager(fn): - def oops(*args, **kw): - raise RuntimeError("Python 2.5 or above is required to use " - "context managers.") - oops.__name__ = fn.__name__ - return oops - class _symbol(object): def __init__(self, name): diff --git a/blinker/base.py b/blinker/base.py index c9f65de..52b9a6b 100644 --- a/blinker/base.py +++ b/blinker/base.py @@ -8,12 +8,12 @@ each manages its own receivers and message emission. The :func:`signal` function provides singleton behavior for named signals. """ +from contextlib import contextmanager from warnings import warn from weakref import WeakValueDictionary from blinker._utilities import ( WeakTypes, - contextmanager, defaultdict, hashable_identity, lazy_property, @@ -416,7 +416,7 @@ class NamedSignal(Signal): def __repr__(self): base = Signal.__repr__(self) - return "%s; %r>" % (base[:-1], self.name) + return "{}; {!r}>".format(base[:-1], self.name) class Namespace(dict): diff --git a/docs/source/index.rst b/docs/source/index.rst index 28976d8..bdb40ef 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -16,8 +16,8 @@ The core of Blinker is quite small but provides powerful features: - thread safety Blinker was written by Jason Kirtand and is provided under the MIT -License. The library supports Python 2.4 or later; Python 3.0 or later; -or Jython 2.5 or later; or PyPy 1.6 or later. +License. The library supports Python 2.7 and Python 3.5 or later; +or Jython 2.7 or later; or PyPy 2.7 or later. Decoupling With Named Signals @@ -17,6 +17,7 @@ setup(name="blinker", long_description=readme, license='MIT License', url='http://pythonhosted.org/blinker/', + python_requires='>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*', classifiers=[ 'Development Status :: 5 - Production/Stable', 'Intended Audience :: Developers', @@ -24,16 +25,8 @@ setup(name="blinker", 'Operating System :: OS Independent', 'Programming Language :: Python', 'Programming Language :: Python :: 2', - 'Programming Language :: Python :: 2.4', - 'Programming Language :: Python :: 2.5', - 'Programming Language :: Python :: 2.6', 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.0', - 'Programming Language :: Python :: 3.1', - 'Programming Language :: Python :: 3.2', - 'Programming Language :: Python :: 3.3', - 'Programming Language :: Python :: 3.4', 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.6', 'Programming Language :: Python :: 3.7', diff --git a/tests/test_signals.py b/tests/test_signals.py index a1172ed..2d6a65a 100644 --- a/tests/test_signals.py +++ b/tests/test_signals.py @@ -48,10 +48,10 @@ def test_meta_connect(): sig = blinker.Signal() sig.connect(receiver) - assert sentinel == [dict(sender=sig, - receiver_arg=receiver, - sender_arg=blinker.ANY, - weak_arg=True)] + assert sentinel == [{'sender': sig, + 'receiver_arg': receiver, + 'sender_arg': blinker.ANY, + 'weak_arg': True}] blinker.receiver_connected._clear_state() @@ -78,7 +78,7 @@ def _test_signal_signals(sender): expected = ('receiver_connected', sig, - dict(receiver=receiver, sender=sender, weak=weak)) + {'receiver': receiver, 'sender': sender, 'weak': weak}) assert sentinel[-1] == expected @@ -87,14 +87,14 @@ def _test_signal_signals(sender): expected = ('receiver_disconnected', sig, - dict(receiver=receiver1, sender=sender)) + {'receiver': receiver1, 'sender': sender}) assert sentinel[-1] == expected # disconnect from ANY and all senders (implicit disconnect signature) sig.disconnect(receiver2) assert sentinel[-1] == ('receiver_disconnected', sig, - dict(receiver=receiver2, sender=blinker.ANY)) + {'receiver': receiver2, 'sender': blinker.ANY}) def test_signal_signals_any_sender(): @@ -486,10 +486,3 @@ def test_named_blinker(): def values_are_empty_sets_(dictionary): for val in dictionary.values(): assert val == set() - -if sys.version_info < (2, 5): - def test_context_manager_warning(): - sig = blinker.Signal() - receiver = lambda sender: None - - assert_raises(RuntimeError, sig.connected_to, receiver) @@ -1,5 +1,5 @@ [tox] -envlist = py25,py26,py27,py30,py31,py32,py33,py34,py35,py36,py37,jython +envlist = py27,py35,py36,py37,jython [testenv] deps=nose |