Skip to content

Commit cfc2ce7

Browse files
committed
-
1 parent 562164a commit cfc2ce7

File tree

8 files changed

+14
-16
lines changed

8 files changed

+14
-16
lines changed

source_py2/python_toolbox/context_management/context_manager.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
See its documentation for more information.
88
'''
99

10-
1110
import sys
1211
import types
1312
import abc
@@ -34,8 +33,7 @@ class ContextManager(DecoratingContextManager):
3433
3534
For more details, see documentation of the containing module,
3635
`python_toolbox.context_manager`.
37-
'''
38-
36+
'''
3937

4038
__metaclass__ = ContextManagerType
4139

@@ -78,7 +76,7 @@ def __enter_using_manage_context(self):
7876

7977

8078
try:
81-
generator_return_value = new_generator.next()
79+
generator_return_value = next(new_generator)
8280
return self if (generator_return_value is SelfHook) else \
8381
generator_return_value
8482

@@ -99,7 +97,7 @@ def __exit_using_manage_context(self, exc_type, exc_value, exc_traceback):
9997

10098
if exc_type is None:
10199
try:
102-
generator.next()
100+
next(generator)
103101
except StopIteration:
104102
return
105103
else:
@@ -114,7 +112,7 @@ def __exit_using_manage_context(self, exc_type, exc_value, exc_traceback):
114112
exc_value = exc_type()
115113
try:
116114
generator.throw(exc_type, exc_value, exc_traceback)
117-
except StopIteration, stop_iteration:
115+
except StopIteration as stop_iteration:
118116
# Suppress the exception *unless* it's the same exception that
119117
# was passed to throw(). This prevents a StopIteration
120118
# raised inside the "with" statement from being suppressed

source_py2/python_toolbox/context_management/context_manager_type.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ def MyContextManager():
3737
'''
3838

3939
__metaclass__ = ContextManagerTypeType
40-
4140

4241
def __new__(mcls, name, bases, namespace):
4342
'''

source_py2/python_toolbox/context_management/context_manager_type_type.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,12 @@
99

1010

1111
class ContextManagerTypeType(type):
12-
'''Metaclass for `ContextManagerType`. Shouldn't be used directly.'''
12+
'''
13+
Metaclass for `ContextManagerType`. Shouldn't be used directly.
14+
15+
Did I just create a metaclass for a metaclass. OH YES I DID. It's like a
16+
double rainbow, except I'm the only one who can see it.
17+
'''
1318

1419
def __call__(cls, *args):
1520
'''

source_py3/python_toolbox/address_tools/object_to_string.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,8 @@ def my_filter(key, value):
202202
my_filter
203203
)
204204

205-
namespace_dict_keys = list(namespace_dict.keys())
206-
namespace_dict_values = list(namespace_dict.values())
205+
namespace_dict_keys = namespace_dict.keys()
206+
namespace_dict_values = namespace_dict.values()
207207

208208

209209
# Split to address parts:

source_py3/python_toolbox/caching/cached_property.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
from python_toolbox import decorator_tools
1111
from python_toolbox import misc_tools
12-
import collections
1312

1413

1514
class CachedProperty(misc_tools.OwnNameDiscoveringDescriptor):
@@ -47,7 +46,7 @@ def __init__(self, getter_or_value, doc=None, name=None,
4746
class; this will save a bit of processing later.
4847
'''
4948
misc_tools.OwnNameDiscoveringDescriptor.__init__(self, name=name)
50-
if isinstance(getter_or_value, collections.Callable) and not force_value_not_getter:
49+
if callable(getter_or_value) and not force_value_not_getter:
5150
self.getter = getter_or_value
5251
else:
5352
self.getter = lambda thing: getter_or_value

source_py3/python_toolbox/context_management/base_classes/decorating_context_manager.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
'''
99

1010

11-
1211
from python_toolbox import decorator_tools
1312

1413

source_py3/python_toolbox/context_management/context_manager.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
'''
99

1010

11-
1211
import sys
1312
import types
1413
import abc

source_py3/python_toolbox/context_management/context_manager_type_type.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
77
See its documentation for more information.
88
'''
9-
import collections
109

1110

1211
class ContextManagerTypeType(type):
@@ -46,7 +45,7 @@ def MyContextManager():
4645
if len(args) == 1:
4746
from .context_manager import ContextManager
4847
(function,) = args
49-
assert isinstance(function, collections.Callable)
48+
assert callable(function)
5049
name = function.__name__
5150
bases = (ContextManager,)
5251
namespace_dict = {

0 commit comments

Comments
 (0)